[FFmpeg-devel] [PATCH] Incorrect Ogg Theora duration
Henrik Gulbrandsen
henrik
Thu Apr 17 23:53:34 CEST 2008
This problem showed up when I was getting ready to deliver my next patch
yesterday. In effect, the duration calculation for Ogg streams seems to
drop the first and last frame. This would be true for all Ogg data, but
it's only noticeable for video at a low frame rate.
The attached examples show the result of
ffmpeg -i video.mp4 -vcodec libtheora -f ogg video.ogv
ffplay -stats video.ogv > report.txt 2>&1
before and after the patch. Here, video.mp4 is exactly 24 seconds long,
at 10 fps. Notice the "Duration: 00:00:23.80, start: 0.100000" part in
the stats given with current code!
/Henrik
P.S. The "granule + 1" part of the patch is not technically correct, but
should work for Theora, Vorbis, FLAC, and Speex, since none of them use
overly complex semantics for the granule position. A more correct way of
handling it would require extra code in each of the supported codecs...
-------------- next part --------------
FFplay version SVN-r12884, Copyright (c) 2003-2008 Fabrice Bellard, et al.
configuration: --enable-libtheora --enable-libvorbis --disable-encoder=vorbis
libavutil version: 49.6.0
libavcodec version: 51.55.0
libavformat version: 52.13.0
libavdevice version: 52.0.0
built on Apr 17 2008 23:20:18, gcc: 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
[theora @ 0x7b21e0]344 bits left in packet 81
[theora @ 0x7b21e0]7 bits left in packet 82
Input #0, ogg, from 'video.ogv':
Duration: 00:00:23.80, start: 0.100000, bitrate: 45 kb/s
Stream #0.0: Video: theora, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 10.00 tb(r)
[theora @ 0x7b21e0]344 bits left in packet 81
[theora @ 0x7b21e0]7 bits left in packet 82
-------------- next part --------------
FFplay version SVN-r12884, Copyright (c) 2003-2008 Fabrice Bellard, et al.
configuration: --enable-libtheora --enable-libvorbis --disable-encoder=vorbis
libavutil version: 49.6.0
libavcodec version: 51.55.0
libavformat version: 52.13.0
libavdevice version: 52.0.0
built on Apr 17 2008 23:20:18, gcc: 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
[theora @ 0x7b2200]344 bits left in packet 81
[theora @ 0x7b2200]7 bits left in packet 82
Input #0, ogg, from 'video.ogv':
Duration: 00:00:24.00, start: 0.000000, bitrate: 45 kb/s
Stream #0.0: Video: theora, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 10.00 tb(r)
[theora @ 0x7b2200]344 bits left in packet 81
[theora @ 0x7b2200]7 bits left in packet 82
-------------- next part --------------
A non-text attachment was scrubbed...
Name: theora_duration.patch
Type: text/x-patch
Size: 1280 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080417/6c267b41/attachment.bin>
More information about the ffmpeg-devel
mailing list