[FFmpeg-devel] Muxing h.264 to MP4 gives broken files

Thorsten Jordan tjordan
Fri Mar 14 12:54:17 CET 2008


Hi there,

Using ffmpeg to write MP4 files with h.264 video gives files that are
not muxed correctly. Playback of these files with mplayer look strange
during the first gop, like the Keyframe is missing, and mplayer reports
that on initial play and also on every seek:

[h264 @ 0x8926e50]warning: first frame is no keyframe

I guess that warning comes also right out of ffmpeg inside mplayer, but
that doesn't matter.

As ffmpeg.c does not configure the video encoder to use b-frames i can
not give a commandline to produce such files. You can use any file as
source and add a

ost->st->codec->max_b_frames=2;

right before avcodec_open() in ffmpeg.c to try this scenario.

I havn't found a related bug report on the ML nor the bugtracker.

There is some interesting additional information though:
If you encode video with b-frames (h264), but give linear increasing
values as pts (decoding order, so to say) instead of what the encoder
gives as pts AND if you state that has_b_frames and max_b_frames of the
context are zero before calling av_interleaved_write_frame, then the
resulting MP4 file seems ok and mplayer doesn't report the "no keyframe"
line.

-- 
Regards, Thorsten




More information about the ffmpeg-devel mailing list