Get information from a video file using FFMPEG

When we have a video or a media file of any kind, and we want to get its metadata information, we can use ffmpeg to get file this data, such as file type, the video codec used in the file, or the codec audio, video resolution or many other relevant information.

In this example we get information from a file example.mp4 with the command:

ffmpeg -i example.mp4 -hide_banner

We are using two parameters:

  • -i is used to indicate the input file from which we are getting the information.
  • -hide_banner. This parameter is used to suppress version and another information printing.

Here you can see the result. In the result appears information about the container file, and some basic and useful information such as video duration (1:45.71) or bitrate (440 kb/s). It also shows that the file has two streams with information about each one. (Stream #0:0 which is the video stream, and Stream #0:1 which is the audio one)

From the video stream we can get the video codec used (h264), video resolution (640px width and 360px height), video bitrate (308 kb/s, this bitrate is only for the video and obviously it is lower than the bitrate for the file) or the images per second of the video (25 frames per second).

From the audio stream we can get information about the codec (aac) or more details about the audio stream (bitrate, output freq)

This is the type of output that we can get more commonly. Video files with one video stream and one audio stream. Anyway ffmpeg supports more complex files and can get information from media files with multiple streams and more complex configurations.

Consider another case, in this case a webm file with no audio track. The file is called video.webm and we get media information with the command:

ffmpeg -i video.webm -hide_banner

In this case we get:

In this case and since this is a video that has no audio track (it has no sound), only one video track (Stream #0:0) appears. In this case the codec is VP8, and video stream has 30 frames per second (29.97 frames per second)

This information obtained by ffmpeg is basic and very useful if you need to work with these files. For example if we wanted to make sure that we have several videos with the same resolution, or with the same frames per second configuration, we should be able to verify the files using this command. Anyway this is basic information and does not appear in a easily format if we want to work with it from another program or script. If those were our needs and ffmpeg is not enough, we could use ffprobe tool included in most ffmpeg installations. ffprobe provides more information, and it displays it in a more manageable format for other applications such as JSON or XML. Use ffprobe to obtain information from video files.

::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::