How can I get the resolution (width and height) for a video file from a linux command line?

前端 未结 9 1320
无人共我
无人共我 2020-12-02 10:22

I\'ve been digging through the mplayer/mencoder and ffmpeg documentation and I can\'t seem to come up with anything. I\'m not especially picky as to the out

9条回答
  •  独厮守ぢ
    2020-12-02 11:11

    Here's an "almost-one-liner" I've concocted around ffprobe for exactly this purpose. Works pretty well for me both on Linux and MacOS.

    #!/bin/bash
    
    B='[[:blank:]]'
    D='[[:digit:]]'
    ffprobe "$1" 2>&1 \
        | grep 'Stream.*Video.*fps' \
        | sed "s/^.*$B\($D$D$D*x$D$D$D*\).*$/\1/"
    

提交回复
热议问题