FFmpeg includes command-line utilities for analyzing multimedia files and retrieving details about their streams. Determining the resolution of a video is useful when verifying media dimensions, selecting appropriate output settings, troubleshooting playback or encoding issues, or preparing media for editing and further processing. This tutorial explains how to get video resolution using FFmpeg.
The ffprobe utility can inspect a media file and return the width and height of its video stream.
Download a sample video file for testing:
curl -sSo test.mp4 https://raw.githubusercontent.com/mediaelement/mediaelement-files/master/big_buck_bunny.mp4
The video resolution can be obtained with the following command:
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 test.mp4
The command outputs:
640x360
Command breakdown:
ffprobe- inpects multimedia files and provides information about their streams.-v error- limits the output to error messages, keeping other diagnostic information out of the result.-select_streams v:0- targets the first video stream found in the input file.-show_entries stream=width,height- requests the width and height properties of the selected video stream.-of csv=s=x:p=0- formats the output as a compact value separated byx, while omitting the field names and additional formatting.test.mp4- identifies the media file whose resolution is being checked.
Leave a Comment
Cancel reply