avatar

ShīnChvën ✨

Effective Accelerationism

Powered by Druid

Read Video Info with FFprobe

Wed Dec 28 2022

FFprobe is a tool bundled with FFmpeg to read video info.

Basic Usage

ffprobe input.mp4

This command returns data in plain text.

Data Format

FFprobe can print data in various formats: default, compact, csv, flat, ini, json, xml.

Let's print data in JSON:

ffprobe -v quiet -print_format json -show_format -show_streams input.mp4
  • -v quiet: Set log level to quiet
  • -print_format json: Print data in JSON format
  • -show_format: Show format info
  • -show_streams: Show streams info

Filter Fields

Video infos are mostly stored in streams and format, you can use -show_entries to filter fields:

ffprobe -v quiet -print_format json -show_entries format=size,bit_rate -show_entries stream=codec_name,height,width input.mp4
  • -show_entries stream=codec_name,height,width: Show codec name, height and width in streams info
  • -show_entries format=size,bit_rate: Show size and bit rate in format info

Available Fields in streams and format according to FFprobe Tips

[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]

Select Video Stream

ffprobe -v quiet -print_format json -show_format -show_streams -select_streams v:0 input.mp4
  • -select_streams v:0: Select the first video stream

Select Audio Stream

ffprobe -v quiet -print_format json -show_format -show_streams -select_streams a:0 input.mp4
  • -select_streams a:0: Select the first audio stream

Print Selected Value Without Key

ffprobe -v quiet -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
# output: 9020.245000

Print Selected Value With Key

ffprobe -v quiet -show_entries format=duration -of default=noprint_wrappers=1 input.mp4
# output: duration=9020.245000