2

I use ffmpeg to convert a video file uploaded via an ASPX web page. ffmpeg conversion works fine.

I want to provide the end-user a progress bar. So I placed an updatPanel on my web page and tried to read the file size ...

  • using fileinfo : ffmpeg freeze
  • using [process.start()] cmd.exe /c dir : ffmpeg freeze
  • using filestream : error ->> file is used by another process
  • using ffmpeg -i X Y 2> log.txt : log is created only when conversion completed

Whats the proper/working way to do this?

Sameera Thilakasiri
  • 9,452
  • 10
  • 51
  • 86
assaf
  • 51
  • 1
  • 4
  • 1
    This may help: http://stackoverflow.com/questions/747982/can-ffmpeg-show-a-progress-bar – xxpor Dec 01 '11 at 22:02
  • Thanks for the insight, I have managed to set the log. a single note for the followers, if you run ffmpeg.exe directly (ie - myprocess.StartInfo.FileName = "ffmpeg.exe") you cant redirect stdoutput. – assaf Dec 02 '11 at 16:10

2 Answers2

9

Use ffprobe command to get video metadada

Only file size:

ffprobe -i video.mp4 -show_entries format=size -v quiet -of csv="p=0"

Complete (return in JSON):

ffprobe -v quiet -print_format json -show_format -show_streams video.mp4
0

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à!

soundflix
  • 928
  • 9
  • 22