wiki:FFprobeTips

ffprobe is a simple multimedia stream analyzer. You can use it to output all kinds of information about an input including duration, frame rate, frame size, etc. It is also useful for gathering specific information about an input to be used in a script.

Usage

ffprobe [OPTIONS] [INPUT_FILE]

Show help

Refer to the manual:

man ffprobe

or show the included help:

ffprobe -h

Scroll to the top of the console output and refer to "Main options" for the most important options.

Examples

Basic example

$ ffprobe -v error -show_format -show_streams input.mp4
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=1/50
codec_tag_string=avc1
codec_tag=0x31637661
width=320
height=240
has_b_frames=2
sample_aspect_ratio=1:1
display_aspect_ratio=4:3
pix_fmt=yuv420p
level=13
color_range=N/A
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
timecode=N/A
refs=4
is_avc=1
nal_length_size=4
id=N/A
r_frame_rate=25/1
avg_frame_rate=25/1
time_base=1/12800
start_pts=0
start_time=0.000000
duration_ts=384000
duration=30.000000
bit_rate=34761
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=750
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
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=VideoHandler
[/STREAM]
[STREAM]
index=1
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=LC
codec_type=audio
codec_time_base=1/44100
codec_tag_string=mp4a
codec_tag=0x6134706d
sample_fmt=fltp
sample_rate=44100
channels=1
channel_layout=mono
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/44100
start_pts=-1024
start_time=-0.023220
duration_ts=1324024
duration=30.023220
bit_rate=56517
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=1293
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
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=SoundHandler
[/STREAM]
[FORMAT]
filename=input.mp4
nb_streams=2
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=-0.023220
duration=30.024000
size=368644
bit_rate=98226
probe_score=100
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2avc1mp41
TAG:title=FFprobe Tips
TAG:encoder=Lavf56.15.101
[/FORMAT]

From the above example, if you would only want size=368644:

$ ffprobe -v error -show_entries format=size -of default=noprint_wrappers=1 input.mp4
size=368644

If you would only want the value with no key:

$ ffprobe -v error -show_entries format=size -of default=noprint_wrappers=1:nokey=1 input.mp4
368644
  • -v sets the loglevel. error will omit the build and "generic" file information, but will allow errors to be shown in addition to the desired ffprobe output.
  • -print_format (or the alias -of) is useful to change the output format. Available formats are: default, compact, csv, flat, ini, json, xml.
  • You can use nw=1:nk=1 instead of noprint_wrappers=1:nokey=1 if you prefer.

Duration

Format (container) duration

$ ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
30.024000

Adding the -sexagesimal option will use the HOURS:MM:SS.MICROSECONDS time unit format:

0:00:30.024000

Stream duration

Duration of the first video stream:

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

Note: Not all formats, such as Matroska and WebM, store duration at the stream level resulting in duration=N/A. Refer to Format (container) duration instead.

Get duration by decoding

You can also use ffmpeg to get the duration by fully decoding the file. The null muxer is used so no output file is created. Refer to time= in the next-to-last line of the console output. In this example the input has a duration of 00:57:28.87.

$ ffmpeg -i input.webm -f null -
...
frame=206723 fps=1390 q=-0.0 Lsize=N/A time=00:57:28.87 bitrate=N/A speed=23.2x
  • This method will report the correct duration in case the methods shown above using ffprobe are incorrect or missing due to corrupt, truncated, or damaged files.
  • The command may take some time depending on the input file duration and decoding complexity.

Frame Rate

This will provide the average frame rate for the first video stream.

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

Example output for a NTSC-film video:

24000/1001

Example output for a PAL video:

25/1
  • Some files can contain multiple video streams.
  • Some streams may be variable frame rate.

Width x Height (resolution)

$ ffprobe -v error -select_streams v:0 -show_entries stream=height,width -of csv=s=x:p=0 input.mp4
  1280x720

See the documentation on other available output formatting styles such as JSON and XML.

Last modified 6 years ago Last modified on Dec 17, 2018, 9:31:35 PM
Note: See TracWiki for help on using the wiki.