[FFmpeg-user] Why does '-c:v copy' decode video frames?

Moritz Barsnick barsnick at gmx.net
Wed Feb 20 10:24:30 EET 2019

On Wed, Feb 20, 2019 at 14:28:12 +0800, Yukun Guo wrote:
> I'm trying to transmux an H.264 movie in FLV container into raw H.264 in
> Annex.B format:
>     ffmpeg -i movie.flv -c:v copy -an -bsf:v h264_mp4toannexb movie.264
> which is further called by `h264dec.c/h264_decode_frame`. What
> confuses me is why does the copy codec still try to decode H.264
> frames and even do motion vector prediction? If I understand
> Could any FFmpeg experts explain why this occurs?

I'm no expert, but a simple backtrace shows me:

Breakpoint 1, h264_decode_frame (avctx=0xa21ac80, data=0xa221c00, got_frame=0xbfffe930, avpkt=0xa221e00) at src/libavcodec/h264dec.c:986
986         if (avctx->codec_id == AV_CODEC_ID_IMM5) {
(gdb) bt
#0  h264_decode_frame (avctx=0xa21ac80, data=0xa221c00, got_frame=0xbfffe930, avpkt=0xa221e00) at src/libavcodec/h264dec.c:986
#1  0x08531e43 in decode_simple_internal (avctx=0xa221e00, frame=0x98c6980) at src/libavcodec/decode.c:433
#2  0x0853009a in decode_simple_receive_frame (avctx=<optimized out>, frame=<optimized out>) at src/libavcodec/decode.c:629
#3  decode_receive_frame_internal (avctx=<optimized out>, frame=<optimized out>) at src/libavcodec/decode.c:647
#4  avcodec_send_packet (avctx=0xa21ac80, avpkt=0xbfffe9d0) at src/libavcodec/decode.c:705
#5  0x084774af in try_decode_frame (s=0xa221e00, st=0x98c6980, avpkt=0xa21ac80, options=0xa21c340) at src/libavformat/utils.c:3079
#6  0x08474220 in avformat_find_stream_info (ic=0xa219740, options=0xa21c340) at src/libavformat/utils.c:3900
#7  0x08055aa0 in open_input_file. () at src/fftools/ffmpeg_opt.c:1126
#8  0x08054cf3 in open_files (l=<optimized out>, inout=<optimized out>, open_file=<optimized out>) at src/fftools/ffmpeg_opt.c:3273
#9  ffmpeg_parse_options (argc=8, argv=0xbffff4b4) at src/fftools/ffmpeg_opt.c:3313
#10 0x0806fff3 in main (argc=8, argv=0xbffff4b4) at src/fftools/ffmpeg.c:4869

libavformat is probing the stream, as far as I can tell, and using the
h264dec functions for this. (It also does so if you give it "-f mp4
-c:v h264".)


More information about the ffmpeg-user mailing list