Skip to content

Instantly share code, notes, and snippets.

@jhallard
Created June 22, 2018 22:42
Show Gist options
  • Save jhallard/b65cdc33950e130a3506c5f5ec85d1d6 to your computer and use it in GitHub Desktop.
Save jhallard/b65cdc33950e130a3506c5f5ec85d1d6 to your computer and use it in GitHub Desktop.
Get the format and encoding information for a video in json format from ffprobe
get_format_info ()
{
ffprobe -v error -select_streams v:0 -show_entries stream -of default=noprint_wrappers=1 -print_format json "$1"
}
# use like get_format_info /tmp/video.mp4
# $ get_format_info /tmp/video.mp4
{
"programs": [
],
"streams": [
{
"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": "18779/1126400",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 1920,
"height": 1080,
"coded_width": 1920,
"coded_height": 1080,
"has_b_frames": 0,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "16:9",
"pix_fmt": "yuvj420p",
"level": 41,
"color_range": "pc",
"color_space": "bt709",
"color_transfer": "bt709",
"color_primaries": "bt709",
"chroma_location": "left",
"refs": 1,
"is_avc": "true",
"nal_length_size": "4",
"r_frame_rate": "30/1",
"avg_frame_rate": "563200/18779",
"time_base": "1/15360",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 169021,
"duration": "11.003971",
"bit_rate": "2094242",
"bits_per_raw_sample": "8",
"nb_frames": "330",
"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"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment