# Media : ffmpeg : ffprobe
## CLI
```
ffprobe test.mp4 -of json [-show_format] [-show_streams]
```
> [!WARNING]
> Without either "show" options, returns empty dict.
## Result
```
format :
filename : "/home/user/test.mp4"
nb_streams : 2
nb_programs : 0
format_name : "mov,mp4,m4a,3gp,3g2,mj2"
format_long_name : "QuickTime / MOV"
start_time : "0.000000"
duration : "10.010000"
size : "2505071"
bit_rate : "2002054"
probe_score : 100
tags :
major_brand : "isom"
minor_version : "512"
compatible_brands : "isomiso2avc1mp41"
title : "Downloaded from RARBG.COM"
encoder : "Lavf61.1.100"
comment : "Downloaded from RARBG.COM"
streams : [
0 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 : "1001/60000"
codec_tag_string : "avc1"
codec_tag : "0x31637661"
width : 1920
height : 1080
coded_width : 1920
coded_height : 1088
closed_captions : 0
has_b_frames : 2
pix_fmt : "yuv420p"
level : 40
chroma_location : "left"
refs : 1
is_avc : "true"
nal_length_size : "4"
r_frame_rate : "30000/1001"
avg_frame_rate : "30000/1001"
time_base : "1/30000"
start_pts : 0
start_time : "0.000000"
duration_ts : 300300
duration : "10.010000"
bit_rate : "1863931"
bits_per_raw_sample : "8"
nb_frames : "300"
disposition :
default : 1
dub : 0
original : 0
comment : 0
lyrics : 0
karaoke : 0
forced : 0
hearing_impaired : 0
visual_impaired : 0
clean_effects : 0
attached_pic : 0
timed_thumbnails : 0
tags :
language : "und"
handler_name : "VideoHandler"
encoder : "Lavc61.3.100 libx264"
1 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 : 2
channel_layout : "stereo"
bits_per_sample : 0
r_frame_rate : "0/0"
avg_frame_rate : "0/0"
time_base : "1/44100"
start_pts : 0
start_time : "0.000000"
duration_ts : 441000
duration : "10.000000"
bit_rate : "128146"
max_bit_rate : "128146"
nb_frames : "432"
disposition :
default : 1
dub : 0
original : 0
comment : 0
lyrics : 0
karaoke : 0
forced : 0
hearing_impaired : 0
visual_impaired : 0
clean_effects : 0
attached_pic : 0
timed_thumbnails : 0
tags :
language : "und"
handler_name : "SoundHandler"
```
## Commentary
###### probe_score
> An input (a file in this case) can have an extension (say ".avi") and be of a different format (a wav file for example). FFmpeg can detect the real format of an input (with ffprobe). In order to do this, it opens the file and read it (the first 5 seconds, set by option `analyzeduration` if I recall correctly). Then, it assign a score to each format: a low score if the data have nothing to do with the input, a high score if the format seems the right one.
>
> The format returned is the one with the highest score. **probe_score** is this score.
>
> 100 is the maximum score, meaning that FFmpeg is sure that the format is the real one. With a score below 25, it is recommanded to increase probe duration.
https://stackoverflow.com/questions/25257986/what-does-probe-score-mean-in-ffprobe-output/25288882#25288882
###### r_frame_rate vs avg_frame_rate
> `r_frame_rate` is "the lowest framerate with which all timestamps can be represented accurately (it is the least common multiple of all framerates in the stream)."
>
> `avg_frame_rate` is total # of frames / total duration
https://github.com/eugeneware/ffprobe/issues/7
## Survey Results
Based on a survey of 4k local video files (with a great deal of variety), I determined the following fields to be the most reliable:
```
format.duration
format.bit_rate
video.codec_name ex: h264, hevc, mjpeg, mpeg2video, mpeg4, vc1, vp8, vp9, wmv3
video.height
video.width
video.avg_frame_rate always one int divided by another
audio.codec_name ex: aac, ac3, eac3, mp2, mp3, opus, pcm_s16be, vorbis, wmapro, wmav2
audio.sample_rate ex: 12000, 16000, 22050, 24000, 44100, 48000
```
###### probe_score
Every video returned "100" except one, which returned "26" for some reason, but still played fine in VLC.