I am but a lowly PHP developer that has been tasked with retrieving some basic information about 100's of thousands of video files. I've had some luck using ffmpeg extracting the video bitrate, video width, video height, duration, and aspect ratio from them, but with an error ratio of about 5%, this still leaves me with an enormous number of files that I don't know how to deal with. The videos DO play, but the massive amount of data that ffmpeg returns in has me baffled as to how parse the returned XML to find what I need with all the conditions that I seem to be encountering. (The files are a collection from the past 15 years or so, some newly encoded, others converted years ago)

At any rate, I found the following use of ffprobe to get duration, and was hoping that someone here who understands the complexities of using ffmpeg & ffprobe would be kind enough in assist me with finding the other values I need in a more straightforward way than the crazy code I'm finding myself creating to climb through the full results of ffmpeg.

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

Thanks so very much in advance.


I should add that with the below cmd, I can "see" what I need, but I don't understand how to extract what I need, e.g. retrieving the VIDEO bitrate, and suppressing/ignoring the AUDIO bitrate, or determining which of 2 different durations to use (Audio/Video durations?)

C:\>ffprobe -v error -show_entries stream=width,height,bit_rate,duration -of default=noprint_wrappers=1 input.mp4


If you only want the information from the first video stream use -select_streams v:0:

ffprobe -v error -select_streams v:0 -show_entries stream=width,height,duration,bit_rate -of default=noprint_wrappers=1 input.mp4

Example output:

| improve this answer | |
  • Thanks so much for the assist....I had to accept the other answer only because I was alerted of it first, and it did the trick.. – GDP Sep 9 '15 at 16:52
  • @GDP Please consider: notified first in this case, because it's the latest answer. – p2or Sep 9 '15 at 17:00
  • @poor I take the rep point quite seriously, but this answer wasn't on my screen to accept until I accept the other, then it appeared, thus the immediate apology. Sorry everyone...really didn't mean to offend. – GDP Sep 9 '15 at 19:44

From https://trac.ffmpeg.org/wiki/FFprobeTips

If you want to get the bit_rate of the 1st video stream you could use:

ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 input.mp4

Where -select_steams v:0 is selecting the 1st video stream and :nokey=1 gives the value without the key. You could also extract the information by piping it to grep but I'm not sure if that's available on your system.

ffprobe -v error -show_entries stream=width,height,bit_rate,duration -of default=noprint_wrappers=1 input.mp4 | grep -oP "(?<=bit_rate\=)[0-9]+"

Hope this helps!

| improve this answer | |
  • "piping it to grep"...sounds like something I might have done as a teenager, lol...THANKS for the assist! – GDP Sep 9 '15 at 16:50
  • Thanks @GDP but LordNeckbeard's is the answer you should probably accept as it was published first – moorej Sep 9 '15 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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