One liner ffmpeg (or other) to get only resolution?
Using ffprobe
from the ffmpeg package:
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input.mp4
Example result:
1280x720
What these options do:
-v error
makes the output less verbose.-select_streams v:0
selects only the first video stream.-show_entries stream=width,height
chooses onlywidth
andheight
from the big list of parameters thatffprobe
can provide.-of csv=s=x:p=0
formats the text output. Thecsv
formatting type is used because it makes a simple output.s=x
makes it use anx
to separate thewidth
andheight
values.p=0
makes it omit thestream
prefix in the output.
See the ffprobe documentation and FFmpeg Wiki: ffprobe tips for more info.
Get video resolution with ffmpeg:
ffmpeg -i filename 2>&1 | grep -oP 'Stream .*, \K[0-9]+x[0-9]+'
Output (e.g.):
640x480
exiftool -b metavideo.mp4 -ImageWidth
exiftool -b metavideo.mp4 -ImageHeight
do the job without any grep
s
One-liner looks like:
exiftool -b metavideo.mp4 -ImageSize
That returns WxH string that you was looking for.