6

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 : qt

minor_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

1
  • Just tested with a few more variations in Quicktime export. It seems that if just pick any frame rate or bitrate to export, ffmpeg still has a much better chance of reporting a more accurate duration. Is Quicktime "Fixing" something? The container?
    – kenitech
    May 17, 2012 at 19:56

2 Answers 2

4

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.

5
  • Thanks for the info. what's the best way to examine a QT file's movie header?
    – kenitech
    May 17, 2012 at 22:46
  • I'm also finding that if I use the '-ss' param and apply the negative start time reported by ffmpeg my file is closer to what I believe to be the correct duration, plus any audio that has been out of sync appears to be resolved. For example: ffmpeg reports video input.mov start: 0.-963005 duration: 00:00:15.97 ffmpeg -i input.mov -ar 22050 -ab 65536 -s 320x240 -b 524288 -r 12 -ss 00:00:00.963005 output.flv result: Duration: 00:00:15.00 sorry, the stackoverflow comment box is driving me nuts.
    – kenitech
    May 17, 2012 at 22:50
  • Not sure what the best method is. I use a custom proprietary library I've built from scratch. Regarding the sync issue, you could also have a look at -async parameter and see if that helps. I think ffmpeg's reported duration may be correct for this file. If you put the file on a timeline which is not based on Quicktime components, such as Adobe Premiere Pro, the reported duration is 15 seconds and 23 frames.
    – BlueVoodoo
    May 17, 2012 at 23:15
  • Thanks. You've pretty much answered my initial question. I'll mark it shortly. I think the time might differ in an editing tool if you're timeline doesn't match the frame rate of the source video, no? In my mind, the actual time a Quicktime .mov plays back should be THE duration of the video. Also, VLC Media player says 00:14. So I am stuck with what is actually happening in real time or what a piece of software is saying it is. I'd like to believe what is actually happening. But that doesn't seem possible here.
    – kenitech
    May 18, 2012 at 15:27
  • I know this was nearly 5 years ago, but I wanted to add that I ran into this with a couple of movie trailer mp4 files, only the videos DID continue to play beyond the ffmpeg reported time. However, the actual 'video' ended at ffmpeg's time and what continued was a poster on one mp4 file and just a black screen on the other mp4. Jan 24, 2017 at 19:26
1

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.

1
  • Thanks for the info cehoyos. Unfortunately, like a lot of folks out there, upgrading is not as simple as one might hope with the current infrastructure. The current version we have in production doesn't even have a version number. The examples I am using to test with here are from a personal shared hosting account I have through site5.com.
    – kenitech
    May 18, 2012 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.