Extracting video information of a video file using ffmpeg

Posted By Akash Sharma | 31-Jan-2013

Extracting Video Information FFMPEG

In this blog I am going to describe you how we can get all information of a video using ffmpeg. FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video.

 

Getting video Information using ffmpeg

The ffmpeg command used to get information of a video is:

Ffmpeg  –i <inputFileName>

I have a video named “ffmpeg_macdonald.3GP” on which I have applied my ffmpeg command. I have uploaded this video in my S3 Amazon bucket. You can download it and try it by yourself.

The URL of the video is:

https://s3.amazonaws.com/oodles-technologies1/blog-images/ffmpeg_macdonald.3GP

 

 

C:\Users\dell\Desktop>ffmpeg -i ffmpeg_macdonald.3GP
ffmpeg version N-45279-g1a104bf Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct 10 2012 19:19:16 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runt
ime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass -
-enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-l
ibfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenj
peg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-li
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --ena
ble-zlib
  libavutil      51. 74.100 / 51. 74.100
  libavcodec     54. 65.100 / 54. 65.100
  libavformat    54. 31.100 / 54. 31.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'macdonald.3GP':
  Metadata:
    major_brand     : 3gp6
    minor_version   : 256
    compatible_brands: isom3gp6
  Duration: 00:00:41.25, start: 0.000000, bitrate: 84 kb/s
    Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p
, 176x144 [SAR 1:1 DAR 11:9], 58 kb/s, 12 fps, 12 tbr, 12 tbn, 12 tbc
    Metadata:
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 22050 Hz, mono, s16, 23 kb
/s
    Metadata:
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
At least one output file must be specified

 

Explanation:

Duration: 00:00:41.25, start: 0.000000, bitrate: 84 kb/s

  • Bit rate = 84 kb/s. This is overall bit rate. This is also called data rate of video.
  • Duration = 00 hour  00 minutes  42 seconds  25 milliseconds

 

Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p

, 176x144 [SAR 1:1 DAR 11:9], 58 kb/s, 12 fps, 12 tbr, 12 tbn, 12 tbc

  • mpeg4 (Simple Profile) (mp4v / 0x7634706D) :

mpeg4 video codec with simple profile.

  •  yuv420p :

‘Y’ stands for the luma component (the brightness) and U and V are the chrominance (color) components; luminance is denoted by Y and luma by Y'.Y'UV signals are typically created from RGB (red, green and blue) source. The primary advantages of luma/chroma systems such as Y'UV, and its relatives Y'IQ and YDbDr , are that they remain compatible with black and white analog television. Another advantage of Y'UV is that some of the information can be discarded in order to reduce bandwidth.

  • 176x144 [SAR 1:1 DAR 11:9]   : 

176 pixels width

144 pixels height

Display aspect ratio

There are two types of aspect ratios involved in video editing. One is display aspect ratio or DAR;  this is the ratio most commonly referred to by the term "aspect ratio", and is the ratio of the video frame's  physical (displayed) width to its height, regardless of the number of pixels used to represent the video image. Typical DAR values are 4:3 for standard-definition video or 16:9 for widescreen television.

pixel aspect ratio

The other type of aspect ratio is pixel aspect ratio, or PAR (also known as "sample aspect ratio" or SAR). This is the ratio of the width to the height of a single pixel in the video image; a PAR of 1:1 means that each pixel is a perfect square, while a PAR of 2:1 would mean that each pixel is a rectangle twice as wide as it is tall. PAR can be used to refer either to the pixels in a video file, or to the pixels on a physical display device such as a television.

These two aspect ratios are related to each other and the number of pixels in the video frame (or display device) as follows:

DAR / PAR = width (pixels) / height (pixels)

 

  •  58 kb/s :

Data Rate  or video bit rate.

Number of bits processed in one sec.

Data Rate < BW        for smooth video streaming

 

  •  12 fps:

No of video frames played per second.

 

  • 12 tbr, 12 tbn, 12 tbc  :

There are three different time bases for time stamps in FFmpeg. The 
values printed are actually reciprocals of these, i.e. 1/tbr, 1/tbn and 
1/tbc. 

tbn is the time base in AVStream that has come from the container, I 
think. It is used for all AVStream time stamps. 

tbc is the time base in AVCodecContext for the codec used for a 
particular stream. It is used for all AVCodecContext and related time 
stamps. 

tbr is guessed from the video stream and is the value users want to see 
when they look for the video frame rate, except sometimes it is twice 
what one would expect because of field rate versus frame rate.

 

Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 22050 Hz, mono, s16, 23 kb/s

  • aac (mp4a / 0x6134706D)

aac audio codec

  • 22050 Hz

audio sampling frequency

  • Mono

Number of audio channels . For 1 it is mono, for 2 it is stereo .It can also a value of x.x .

  • 23 kb/s

audio bits processed per second.

 

Getting video Information using ffprobe

There is a tool named “ffprobe” which you get with ffmpeg. This also helps us to see video information.

Command of ffprobe to get video information:

ffprobe  -show_streams  –i  <inputFileName>

In this we can see all the parameters of a video in key-value pair.

 

 

C:\Users\dell\Desktop>ffprobe -show_streams ffmpeg_macdonald.3GP
ffprobe version N-45279-g1a104bf Copyright (c) 2007-2012 the FFmpeg developers
  built on Oct 10 2012 19:19:16 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runt
ime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass -
-enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-l
ibfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenj
peg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-li
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --ena
ble-zlib
  libavutil      51. 74.100 / 51. 74.100
  libavcodec     54. 65.100 / 54. 65.100
  libavformat    54. 31.100 / 54. 31.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.102 /  3. 19.102
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
  libpostproc    52.  1.100 / 52.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ffmpeg_macdonald.3GP':
  Metadata:
    major_brand     : 3gp6
    minor_version   : 256
    compatible_brands: isom3gp6
  Duration: 00:00:41.25, start: 0.000000, bitrate: 84 kb/s
    Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p
, 176x144 [SAR 1:1 DAR 11:9], 58 kb/s, 12 fps, 12 tbr, 12 tbn, 12 tbc
    Metadata:
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 22050 Hz, mono, s16, 23 kb
/s
    Metadata:
      handler_name    : IsoMedia File Produced by Google, 5-11-2011
[STREAM]
index=0
codec_name=mpeg4
codec_long_name=MPEG-4 part 2
profile=Simple Profile
codec_type=video
codec_time_base=1/12
codec_tag_string=mp4v
codec_tag=0x7634706d
width=176
height=144
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=11:9
pix_fmt=yuv420p
level=0
timecode=N/A
quarter_sample=0
divx_packed=0
id=N/A
r_frame_rate=12/1
avg_frame_rate=12/1
time_base=1/12
start_pts=0
start_time=0.000000
duration_ts=495
duration=41.250000
bit_rate=58391
nb_frames=495
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=und
TAG:handler_name=IsoMedia File Produced by Google, 5-11-2011
[/STREAM]
[STREAM]
index=1
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=unknown
codec_type=audio
codec_time_base=1/22050
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=s16
sample_rate=22050
channels=1
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/22050
start_pts=0
start_time=0.000000
duration_ts=909312
duration=41.238639
bit_rate=23999
nb_frames=888
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
TAG:language=und
TAG:handler_name=IsoMedia File Produced by Google, 5-11-2011
[/STREAM]

 

 

Akash Sharma

akash.sharma@oodlestechnologies.com

 

Request for Proposal

Recaptcha is required.

Sending message..