How would I get the height and width of a video from ffmpeg\'s information output. For example, with the following output:
$ ffmpeg -i video.mp4
ffprobeffprobe -v error -show_entries stream=width,height -of default=noprint_wrappers=1 input.mp4
width=1280
height=720
ffprobe -v error -show_entries stream=width,height -of csv=p=0:s=x input.m4v
1280x720
ffprobe -v error -show_entries stream=width,height -of json input.mkv
{
"programs": [
],
"streams": [
{
"width": 1280,
"height": 720
},
{
}
]
}
What the options do:
-v error Make a quiet output, but allow errors to be displayed. Excludes the usual generic FFmpeg output info including version, config, and input details.
-show_entries stream=width,height Just show the width and height stream information.
-of option chooses the output format (default, compact, csv, flat, ini, json, xml). See FFprobe Documentation: Writers for a description of each format and to view additional formatting options.
-select_streams v:0 This can be added in case your input contains multiple video streams. v:0 will select only the first video stream. Otherwise you'll get as many width and height outputs as there are video streams.
See the FFprobe Documentation and FFmpeg Wiki: FFprobe Tips for more info.