ffprobe (with examples)
Display all available stream info for a media file
The command ffprobe -v error -show_streams input.mp4
is used to display all available stream information for a media file.
-v error
sets the verbosity level to error, which suppresses all non-error messages.-show_streams
specifies that stream information should be displayed.
Example usage:
ffprobe -v error -show_streams input.mp4
Example output:
[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=1920
height=1080
coded_width=1920
coded_height=1088
has_b_frames=2
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=40
color_range=N/A
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=unknown
timecode=N/A
refs=1
is_avc=true
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=3840000
duration=300.000000
bit_rate=9966504
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=3750
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
DISPOSITION:timed_thumbnails=0
[/STREAM]
Display media duration
The command ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
is used to display the duration of a media file.
-v error
sets the verbosity level to error, which suppresses all non-error messages.-show_entries format=duration
specifies that the duration of the media file should be displayed.-of default=noprint_wrappers=1:nokey=1
formats the output to only display the value without any additional information.
Example usage:
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
Example output:
300.000000
Display the frame rate of a video
The command ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 input.mp4
is used to display the frame rate of a video.
-v error
sets the verbosity level to error, which suppresses all non-error messages.-select_streams v:0
selects the first video stream.-show_entries stream=avg_frame_rate
specifies that the average frame rate of the video stream should be displayed.-of default=noprint_wrappers=1:nokey=1
formats the output to only display the value without any additional information.
Example usage:
ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 input.mp4
Example output:
25/1
Display the width or height of a video
The command ffprobe -v error -select_streams v:0 -show_entries stream=width|height -of default=noprint_wrappers=1:nokey=1 input.mp4
is used to display the width or height of a video.
-v error
sets the verbosity level to error, which suppresses all non-error messages.-select_streams v:0
selects the first video stream.-show_entries stream=width|height
specifies that the width or height of the video stream should be displayed.-of default=noprint_wrappers=1:nokey=1
formats the output to only display the value without any additional information.
Example usage (for width):
ffprobe -v error -select_streams v:0 -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 input.mp4
Example output (for width):
1920
Example usage (for height):
ffprobe -v error -select_streams v:0 -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 input.mp4
Example output (for height):
1080
Display the average bit rate of a video
The command ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 input.mp4
is used to display the average bit rate of a video.
-v error
sets the verbosity level to error, which suppresses all non-error messages.-select_streams v:0
selects the first video stream.-show_entries stream=bit_rate
specifies that the bit rate of the video stream should be displayed.-of default=noprint_wrappers=1:nokey=1
formats the output to only display the value without any additional information.
Example usage:
ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 input.mp4
Example output:
9966504
By using the various ffprobe
commands described above, users can effectively analyze different aspects of media files. These commands are particularly useful when working with multimedia files and require detailed information about the streams within those files. The simplicity of the commands and the availability of specific stream information enable users to make informed decisions when processing or working with media files.