Getting information about a video file on Linux with the command line is very easy. I will show how you can easily find the resolution of a video and the format.
This example below will return the resolution of a video file.
jason@jason-desktop:~/Videos$ ffprobe XR_3DA_2019_03_16_19_22_35_777.avi 2>&1 | grep -E '[[:digit:]]{3,}x[[:digit:]]{3,}' | awk '{print $11}' 1920x1080 |
And this one-liner will return the duration of a video file.
jason@jason-desktop:~/Videos$ ffprobe campfire.ogv 2>&1 | grep "Duration:" | awk '{print $2}' | cut -d "," -f1 00:00:17.13 |
This is how to get the bitrate of a video file very easily. This is in kilobits per second.
jason@jason-desktop:~/Videos$ ffprobe XR_3DA_2019_03_16_19_22_35_777.avi 2>&1 | grep "Duration:" | awk '{print $6}' | cut -d "," -f1 234018 |
This is a nice way to capture a thumbnail of a video. This command will capture a 320-pixel wide thumbnail of a video and save it as a png file.
jason@jason-desktop:~/Videos$ ffmpegthumbnailer -i XR_3DA_2019_03_16_19_22_35_777.avi -s 320 -o stalker.png |
This could be very useful in a script.
Mplayer can also be used to get comprehensive video information. This example will return the resolution of the video and other information.
1 2 3 4 5 6 7 8 9 10 | jason@jason-desktop:~/Videos$ mplayer -vo null -ao null -frames 0 -identify XR_3DA_2019_03_16_19_22_35_777.avi 2>&1 | grep VIDEO ID_VIDEO_ID=0 VIDEO: [MJPG] 1920x1080 24bpp 30.000 fps 232478.8 kbps (28378.8 kbyte/s) ID_VIDEO_CODEC=ffmjpeg ID_VIDEO_FORMAT=MJPG ID_VIDEO_BITRATE=232478768 ID_VIDEO_WIDTH=1920 ID_VIDEO_HEIGHT=1080 ID_VIDEO_FPS=30.000 ID_VIDEO_ASPECT=0.0000 |
This final example will print the number of frames in a video file.
jason@jason-desktop:~/Videos$ ffprobe -select_streams v -show_streams footage.avi 2>&1 | grep nb_frames | cut -d "=" -f2 1724 |
This is a great example of how versatile Linux is when getting information about files. Media files contain very useful metadata and getting this to the terminal is very easy to do.