7

I have an oldish build of FFmpeg that I can't easily change.

We use FFmpeg to find the duration of video and sound files. So far it has been working wonderfully.

Recently on an uploaded file, FFmpeg has reported a 30 second file as being 5 minutes 30 seconds in length.

Could it be something wrong with the file rather than FFmpeg?

If I use FFmpeg to convert to another file, the duration is restored.

In case it matters, ffmpeg -i 'path to the file' produces:

FFmpeg version Sherpya-r15618, Copyright (c) 2000-2008 Fabrice Bellard, et al.
  libavutil     49.11. 0 / 49.11. 0
  libavcodec    52. 0. 0 / 52. 0. 0
  libavformat   52.22. 1 / 52.22. 1
  libavdevice   52. 1. 0 / 52. 1. 0
  libswscale     0. 6. 1 /  0. 6. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Oct 14 2008 23:43:47, gcc: 4.2.5 20080919 (prerelease) [Sherpya]
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'H:\path\to\file.mov':
  Duration: 00:05:35.00, start: 0.000000, bitrate: 1223 kb/s
    Stream #0.0(eng): Audio: aac, 44100 Hz, stereo, s16
    Stream #0.1(eng): Video: h264, yuv420p, 720x576, 25.00 tb(r)
Must supply at least one output file

It's that very command I use to then extract the duration with RegEx.

Does anyone have a nice application that can do what I'm trying above but get it right 100% of the time?

Adrian Lynch
  • 8,237
  • 2
  • 32
  • 40
  • If you still have the file, report it here: http://ffmpeg.org/bugreports.html – alex strange Dec 05 '09 at 07:35
  • I notice it too with aac files http://superuser.com/questions/121298/have-ffmpeg-scan-and-report-correct-time –  Mar 18 '10 at 16:44
  • 1
    Did you ever get to the bottom of this - I am seeing the same thing. Like you I find that other applications (e.g. Quicktime) can read the duration correctly. – Mick Feb 04 '11 at 18:31
  • I have a related question: http://superuser.com/questions/728687/why-does-ffmpeg-segment-times-create-webm-files-with-incorrect-duration-and-star FFmpeg is adding incorrect metadata (duration and start time) in my destination files. – Ryan Mar 13 '14 at 20:33
  • http://stackoverflow.com/questions/10640088/why-does-ffmpeg-report-different-durations?rq=1 i find out [answer](http://stackoverflow.com/questions/10640088/why-does-ffmpeg-report-different-durations?rq=1) here.. as i was also finding this .. – Vikas Rana Dec 31 '15 at 09:17

5 Answers5

4

You should not rely on the stderr.

The stderr output is not intended to be machine parsed: it is for informational purposes only and prone to breakage.

Parse it with

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
30.024000

You can also use ffmpeg to get the duration by fully decoding the file.

ffmpeg -i input.webm -f null -
...
frame=206723 fps=1390 q=-0.0 Lsize=N/A time=00:57:28.87 bitrate=N/A speed=23.2x

For detail refer to Format (container) duration

LF00
  • 27,015
  • 29
  • 156
  • 295
3

Check it with a newer version of ffmpeg (you don't have to replace your build), and if it gives the same duration you can probably blame the file.

Malfist
  • 31,179
  • 61
  • 182
  • 269
2

You can try tcprobe, part of transcode pack.

Sunny Milenov
  • 21,990
  • 6
  • 80
  • 106
2

I'd guess it's a problem with the file. The length is probably written in a header incorrectly. Unfortunately there is no such thing as a validator (like for web standards) so you can't know for sure if a file is correct.

SpliFF
  • 38,186
  • 16
  • 91
  • 120
0

Make sure you are defining the channel and the frequency that is known for the file. Also make sure you are defining the format using -f. Check ffmpeg -formats to view all the available ones.

Use -ac to define the channel. Use -ar to define the rate for the audio. If it is defaulting the bitrate or frequency then the duration will be different than the actual.

Internet
  • 1
  • 1