Source videos: http://www.artworknotavailable.com/tmp/ffmpegtest
Quicktime Pro 7.7.1 Inspector (Win 7) reports the following for the file 2398.mov
4.19MB
H.264
Movie FPS: 23.98
Data Rate: 2.35 mbits/Sec
Duration 14:97
ffmpeg reports the following (see full ffmpeg version info at bottom of post)
ffmpeg -i 2398.mov
Seems stream 1 codec frame rate differs from container frame rate: 47952.00 (47952/1) -> >23.98 (2997/125)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2398.mov':
Metadata:
major_brand : qtminor_version : 537199360
compatible_brands: qt
Duration: 00:00:15.97, start: 0.-963005, bitrate: 2210 kb/s
Stream #0.0(eng): Audio: aac, 48000 Hz, stereo, s16, 152 kb/s
Stream #0.1(eng): Video: h264, yuv420p, 848x480, 2060 kb/s, 23.98 fps, 23.98 tbr, 23976 tbn, 47952 tbc
One second longer than what Quicktime reports.
As an experiment I exported this file from Quicktime Pro using the following settings:
Frame Rate: Current
Key Frames: Every 24 frames
Frame Reordering On
Quality: High
Encoding Best
Data Rate: Automatic
Optimized for Download
Output file: qtime-export-2398.mov
Quicktime Inspector reports:
5.62 MB
H.264
Movie FPS: 23.98
Data Rate: 3.15 mbits/Sec
Duration 14:97
ffmpeg now reports:
ffmpeg -i qtime-export-2398.mov
Seems stream 1 codec frame rate differs from container frame rate: 1200.00 (1200/1) -> 23.98 (24000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'qtime-export-2398.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
Duration: 00:00:14.96, start: 0.000000, bitrate: 3153 kb/s
Stream #0.0(eng): Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
Stream #0.1(eng): Video: h264, yuv420p, 678x384, 1738 kb/s, 23.98 fps, 23.98 tbr, 600 tbn, 1200 tbc
ffmpeg's report on duration went from 15.97 to 14.96 (I can live with .1)
Is this duration calculated from the bitrate?
I need to accurately report the duration of uploaded videos as well as convert them to FLV. Can somebody tell me what is going on here and how I might get around this?
ffmpeg info below. I've tried this on 2 completely different installs/versions of ffmpeg. Same result.
FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers built on Jan 29 2012 23:55:02 with gcc 4.1.2 20080704 (Red Hat 4.1.2-51) configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab libavutil 50.15. 1 / 50.15. 1 libavcodec 52.72. 2 / 52.72. 2 libavformat 52.64. 2 / 52.64. 2 libavdevice 52. 2. 0 / 52. 2. 0 libavfilter 1.19. 0 / 1.19. 0 libswscale 0.11. 0 / 0.11. 0 libpostproc 51. 2. 0 / 51. 2. 0 FFmpeg 0.6.5 libavutil 50.15. 1 / 50.15. 1 libavcodec 52.72. 2 / 52.72. 2 libavformat 52.64. 2 / 52.64. 2 libavdevice 52. 2. 0 / 52. 2. 0 libavfilter 1.19. 0 / 1.19. 0 libswscale 0.11. 0 / 0.11. 0 libpostproc 51. 2. 0 / 51. 2. 0
FFmpeg shows "Duration: 00:00:14.96" here, please understand that your version of FFmpeg is ancient (and has many known bugs and regressions), please see http://ffmpeg.org/download.html for information on how to get current git head, which is always recommended.
I just had a look at the first file and here is why they report a different duration.
Quicktime is collecting the duration value from the "movie header". The values here are 8981 / 600 = 14.97 seconds.
FFmpeg is collecting the duration value from the "media header" which is 383000 / 23976 = 15.97 seconds for the video and 719872 / 48000 = 15.00s for the audio.
Edit: ...and to also answer your other question: Can somebody tell me how I might get around this? I imagine you are using ffmpeg to convert the files to .FLV? If so, I would stick to what ffmpeg reports.