[FFmpeg-devel] [PATCH] Support for variable frame duration

Henrik Gulbrandsen henrik
Tue Apr 22 11:10:49 CEST 2008

On Fri, Apr 18, 2008 at 07:06:00AM +0200, Henrik Gulbrandsen wrote:
> Well, time for the bug I am really trying to fix. What I have is a small
> slide show generated as a set of timed JPEG images in an MP4 container.
> This file should be converted to various other video formats, but FFmpeg
> currently doesn't cope well with randomly varying frame durations.
> The original set of test slides and Ogg Theora files generated before
> and after my preliminary patch attempt are found at the following URLs:
>     http://www.gulbra.net/ffmpeg-devel/movies/slides.mov
>     http://www.gulbra.net/ffmpeg-devel/movies/before_video_duration_patch.ogv
>     http://www.gulbra.net/ffmpeg-devel/movies/after_video_duration_patch.ogv
> Attached output of the mp4info and mp4videoinfo tools from MPEG4IP shows
> what the slides.mov file looks like. It's exactly 24 seconds long, with
> new slides appearing at 1, 2, 3, 4, 6, 8, 12, and 16 seconds. Each slide
> shows the slide number and the time when it should ideally be presented.
> Now, in an attempt to make a minimal patch set, I am trying to fix the
> problem by hooking into the existing video synchronization code. This is
> based on syncing all the way up to the next PTS, so it requires correct
> duration info from the demuxer. Replacing our pts with next_pts actually
> does the right thing (in terms of frame count) without other changes, so
> there may potentially have been an off-by-one problem in the past...
> These changes are more central, more extensive, and probably much more
> controversial than my earlier patches, so feel free to flame me now! :-)
> I haven't checked the regression tests either, but will be back with any
> needed updates within a day or two. Right now, I have a train to catch.

On Fri, 2008-04-18 at 14:10 +0200, Michael Niedermayer wrote:
> The change to mov demuxer change might be ok (ill leave it to baptiste to
> review)
> Ill review the ffmpeg change after you confirm that the regression tests
> do passs.
> Also mov and ffmpeg changes are independant and should be 2 seperate
> patches.

Two separate patches are attached. The regression tests pass now, after
complaining about two small problems: First, packet duration should have
been interpreted in stream time base units rather than codec time base.
Second, the corrected(?) version of video sync wanted to compensate for
the one-frame MPEG codec latency by duplicating the first frame when it
arrived in time for the second presentation interval. I had to update
sync_opts to keep it from doing that.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: video_duration_ffmpeg.patch
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080422/41bdbe7e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: video_duration_mov.patch
Type: text/x-patch
Size: 1108 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080422/41bdbe7e/attachment-0001.bin>

More information about the ffmpeg-devel mailing list