[FFmpeg-devel] delayed H.264 B frames not being flushed by the decoder

declan harrison harrison.declan at gmail.com
Thu Jul 3 00:28:12 CEST 2014


I have a problem which is causing some issues for me. Im using the ffmpeg,
libav API within my application.

 I have an input MP4 file with an H264 video stream and an AAC audio
stream.  The input video stream is encoded at High profile.

I transcode these two streams at a lower bitrate and then output to an MP4
container.   I also output the H.264 profile to baseline (no B frames).

The  the last 2 frame I send to the decoder are P then B frame. After input
is EOF I call the decoder with NULL packet to flush out the remaining
frames.  This causes the P frame (2nd last frame) to be returned and marked
as complete which I can then encode and mux out, The decoder then returns
the last frame (B) to be returned.  However when I encode this one its
marked as incomplete and cant be muxed out.

At this point I then attempt to flush out all delayed frames in the encoder
by calling encode with a null picture type to flush the frames out.
 However the last frame is marked as incompelte and cannot be written.

There are 177 samples in the video track.

Note: Put file through H264 Visa, it indicates that the last B frame which
is sample number 177 is decoded as frame 176 and the sample number 176 (P
frame 2 nd last sample) is decoded as frame 177.

Is there anything I need to do to get this frame to be output


More information about the ffmpeg-devel mailing list