Another idea is to search for duration
and progressed media time
from ffmpeg stderr. It is a funny 'winding road' exercise of string parsing, but it saves you from using other external tools.
In the following, I outline how this can work, the actual code depends on the language of your choice.
In your ffmpeg command, set -loglevel level
:
This will prefix the lines you are interested in with [info]
, just to make it a little easier.
In ffmpeg stderr, search for duration
and time
:
You will need the timecode values.
This is an example of how the line for duration
looks:
[info] Duration: 00:00:46.88, start: 0.000000, bitrate: 2783 kb/s
This is an example of how all the lines for time
look:
[info] frame= 760 fps=313 q=4.0 size= 145152kB time=00:00:31.95 bitrate=37208.5kbits/s speed=13.2x
Next, you need to convert the timecode string to a value in frames or seconds. Tip: ffmpeg uses milliseconds, which is 100 fps :-)
The progress value is time / duration
, which you can use to display progress, voilà!