Answers.Body: <p><a href="https://trac.ffmpeg.org/wiki/FFprobeTips" rel="nofollow noreferrer">Source</a></p>
  <p>If you want to get the <code>bit_rate</code> of the first video stream you could use:</p>
  <pre class="lang-sh prettyprint-override"><code>ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate \
  -of default=noprint_wrappers=1:nokey=1 input.mp4
  </code></pre>
  <p>Where <code>-select_steams v:0</code> is selecting the first video stream and <code>:nokey=1</code> 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.</p>
  <pre class="lang-sh prettyprint-override"><code>ffprobe -v error -show_entries stream=width,height,bit_rate,duration \
  -of default=noprint_wrappers=1 input.mp4 | grep -oP &quot;(?&lt;=bit_rate\=)[0-9]+&quot;
  </code></pre>
  <p>Hope this helps!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-09T16:50:03.220Z
Answers.Text: "piping it to grep"...sounds like something I might have done as a teenager, lol...THANKS for the assist!
Answers.UserDisplayName: GDP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-09T17:06:47.133Z
Answers.Text: Thanks @GDP but LordNeckbeard's is the answer you should probably accept as it was published first
Answers.UserDisplayName: moorej
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-09-09T16:43:27.463Z
Answers.LastActivityDate: 2021-07-09T07:26:29.443Z
Answers.LastEditDate: 2021-07-09T07:26:29.443Z
Answers.UserDisplayName: moorej
Answers.Body: <p>If you only want the information from the first video stream use <code>-select_streams v:0</code>:</p>
  
  <pre><code>ffprobe -v error -select_streams v:0 -show_entries stream=width,height,duration,bit_rate -of default=noprint_wrappers=1 input.mp4
  </code></pre>
  
  <p>Example output:</p>
  
  <pre><code>width=640
  height=480
  duration=10.000000
  bit_rate=942704
  </code></pre>
  
  <ul>
  <li>To see a list all entries use <code>-show_streams</code> and/or <code>-show_format</code> instead of <code>-show_entries</code>.</li>
  <li>See <a href="https://ffmpeg.org/ffprobe.html#Writers" rel="noreferrer">FFprobe Documentation: Writers</a> for various output formatting styles.</li>
  <li>See <a href="https://trac.ffmpeg.org/wiki/FFprobeTips" rel="noreferrer">FFmpeg Wiki: FFprobe</a> for more examples.</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-09T16:52:43.607Z
Answers.Text: 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..
Answers.UserDisplayName: GDP
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-09T17:00:29.147Z
Answers.Text: @GDP Please consider: notified first in this case, because it's the latest answer.
Answers.UserDisplayName: p2or
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-09T19:44:05.663Z
Answers.Text: @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.
Answers.UserDisplayName: GDP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-09-09T16:37:55.197Z
Answers.LastActivityDate: 2019-04-14T19:23:02.497Z
Answers.LastEditDate: 2019-04-14T19:23:02.497Z
Answers.UserDisplayName: llogan
Body: <p>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 <code>ffmpeg</code> and extracting the <code>video bitrate</code>, <code>video width</code>, <code>video height</code>, <code>duration</code>, and <code>aspect ratio</code> 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 <code>ffmpeg</code> returns in has me baffled as to how parse the returned <em>XML</em> 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)</p>
  <p>At any rate, I found the following use of <code>ffprobe</code> to get duration, and was hoping that someone here who understands the complexities of using <code>ffmpeg</code> &amp; <code>ffprobe</code> would be kind enough to assist me with finding the other values I need in a more straightforward way than the crazy code I'm using myself, created to climb through the full results of <code>ffmpeg</code>.</p>
  <pre class="lang-sh prettyprint-override"><code>ffprobe -i &quot;video.mp4&quot; -show_entries format=duration -v quiet -of csv=&quot;p=0&quot;
  </code></pre>
  <p>Thanks so very much in advance.</p>
  <p><strong>CLARIFICATION:</strong></p>
  <p>I should add that with the below cmd, I can <em>&quot;see&quot;</em> 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?)</p>
  <pre class="lang-sh prettyprint-override"><code>C:\&gt;ffprobe -v error -show_entries stream=width,height,bit_rate,duration \
  -of default=noprint_wrappers=1 input.mp4
  </code></pre>
  <pre class="lang-sh prettyprint-override"><code>duration=1712.000000
  bit_rate=64000
  width=320
  height=240
  duration=1711.946113
  bit_rate=359827
  duration=1712.000000
  bit_rate=N/A
  duration=1712.000000
  bit_rate=N/A
  </code></pre>
  
Tags: <ffmpeg>
Title: How to use ffprobe to obtain certain information about mp4/h.264 files
UserDisplayName: GDP
ThreadText: # How to use ffprobe to obtain certain information about mp4/h.264 files
  
  (Asked by: username_0 on 2015-09-09)
  
  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` and 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 to assist me with finding the other values I need in a more straightforward way than the crazy code I'm using myself, created to climb through the full results of `ffmpeg`.
  
  ```sh
  ffprobe -i "video.mp4" -show_entries format=duration -v quiet -of csv="p=0"
  
  ```
  
  Thanks so very much in advance.
  
  **CLARIFICATION:**
  
  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?)
  
  ```sh
  C:\>ffprobe -v error -show_entries stream=width,height,bit_rate,duration \
  -of default=noprint_wrappers=1 input.mp4
  
  ```
  
  ```sh
  duration=1712.000000
  bit_rate=64000
  width=320
  height=240
  duration=1711.946113
  bit_rate=359827
  duration=1712.000000
  bit_rate=N/A
  duration=1712.000000
  bit_rate=N/A
  
  ```
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-09-09. Score: 30 | Accepted answer
  
  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:
  
  ```
  width=640
  height=480
  duration=10.000000
  bit_rate=942704
  
  ```
  
  * To see a list all entries use `-show_streams` and/or `-show_format` instead of `-show_entries`.
  * See [FFprobe Documentation: Writers](https://ffmpeg.org/ffprobe.html#Writers) for various output formatting styles.
  * See [FFmpeg Wiki: FFprobe](https://trac.ffmpeg.org/wiki/FFprobeTips) for more examples.
  
  > **Comments:**
  > **username_0**: 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..  
  > **username_3**: @username_0 Please consider: notified first in this case, because it's the latest answer.  
  > **username_0**: @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.  
  
  ---
  
  ### Answer by username_1 on 2015-09-09. Score: 11
  
  [Source](https://trac.ffmpeg.org/wiki/FFprobeTips)
  
  If you want to get the `bit_rate` of the first video stream you could use:
  
  ```sh
  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 first 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.
  
  ```sh
  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!
  
  > **Comments:**
  > **username_0**: "piping it to grep"...sounds like something I might have done as a teenager, lol...THANKS for the assist!  
  > **username_1**: Thanks @username_0 but LordNeckbeard's is the answer you should probably accept as it was published first  
  
  ---
  
  