FFmpeg is a highly versatile tool that supports encoding, decoding, conversion, and streaming for various video and audio formats.
Steps:
- Installing FFmpeg: First, verify that FFmpeg is installed on your system. Check its installation and version by running
ffmpeg -versionin the command line. - Viewing Video Information with FFmpeg: To retrieve the codec information of a video file, use the
-i(input) option followed by the filename, combined with-hide_bannerto minimize extra output. The command format is:
bashffmpeg -i <filename> -hide_banner
Example:
Suppose you have a file named example.mp4 and want to identify its video codec. Run the following command in the command line:
bashffmpeg -i example.mp4 -hide_banner
Output Analysis:
The output of this command provides detailed information about the file, including details of video and audio streams. The video stream section typically specifies the codec used. For example, the output may include a line similar to:
shellStream #0:0(eng): Video: H.264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 2771 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 60 tbc (default)
Here, Video: H.264 indicates that the video stream uses the H.264 codec.
Summary:
This is a straightforward method to check the codec used by a video file. FFmpeg not only displays the codec type but also provides additional information such as frame rate, bitrate, and resolution, which is highly useful for video processing and optimization.