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

前端 未结 9 1255
无人共我
无人共我 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:09

    Try midentify.sh (TOOLS/midentify.sh in the source code tree of MPlayer).

    It will show information in a parseable format:

    $  ./midentify.sh /data/myvid.flv 
    ID_VIDEO_ID=0
    ID_AUDIO_ID=1
    ID_FILENAME=/data/myvid.flv
    ID_DEMUXER=lavfpref
    ID_VIDEO_FORMAT=VP6F
    ID_VIDEO_BITRATE=0
    ID_VIDEO_WIDTH=640
    ID_VIDEO_HEIGHT=480
    

    [,,,]

    0 讨论(0)
  • 2020-12-02 11:10

    MediaInfo has a command line version and provides the dimensions together with tons of other information.

    0 讨论(0)
  • 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/"
    
    0 讨论(0)
提交回复
热议问题