How to get information about a video file with the Linux command line.

Posted: November 26, 2017. At: 10:58 AM. This was 3 weeks ago. Post ID: 11549
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

Linux shell on a typewriter.
Linux shell on a typewriter.

The Linux command line may be used to get information about a video file easily. Here is an example.

Getting the video resolution with a simple command.

jason@jason-desktop:~/Videos$ ffprobe -v quiet -print_format json -show_format -show_streams burnout-in-a-town-street.mp4 | grep coded
            "coded_width": 400,
            "coded_height": 224,

Return the video codec information.

jason@jason-desktop:~/Videos$ ffprobe -v quiet -print_format json -show_format -show_streams burnout-in-a-town-street.mp4 | grep codec
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "codec_type": "video",
            "codec_time_base": "1/60",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "codec_type": "audio",
            "codec_time_base": "1/44100",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",

Another way with mplayer.

jason@jason-desktop:~/Videos$ mplayer -really-quiet -ao null -vo null -identify -frames 0 burnout-in-a-town-street.mp4 | grep VIDEO
do_connect: could not connect to socket
connect: No such file or directory
ID_VIDEO_ID=0
ID_VIDEO_CODEC=ffh264
ID_VIDEO_FORMAT=H264
ID_VIDEO_BITRATE=280712
ID_VIDEO_WIDTH=400
ID_VIDEO_HEIGHT=224
ID_VIDEO_FPS=30.000
ID_VIDEO_ASPECT=0.0000

Another method.

jason@jason-desktop:~/Videos$ ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width burnout-in-a-town-street.mp4 
streams_stream_0_width=400
streams_stream_0_height=224

No comments have been made. Use this form to start the conversation :)

Leave a Reply