Get aspect ratio of video from FFmpeg

2020-02-24 01:23发布

I am using FFmpeg to convert a video from one format to another. I need to extract the aspect ratio of the video first. How can I find that information?

标签: ffmpeg
2条回答
老娘就宠你
2楼-- · 2020-02-24 01:48

Just run

ffmpeg -i <yourfilename>

and details about the video stream/s contained in the file will be printed to the screen. Two of the parameters listed for each video stream will be the PAR (Pixel Aspect Ratio) and DAR(Display Aspect Ratio). You'll see something like this:

 Stream #0.10[0x258]: Video: mpeg2video, yuv420p, 720x576 [PAR 64:45 DAR 16:9], 4350 kb/s, 27.97 fps, 25 tbr, 90k tbn, 50 tbc

The DAR is what ratio the final displayed video will have. The PAR indicates how the pixels have to be sized to achieve this. For example, in the case I just showed, (720*64)/(576*45) = 16/9.

Many times, PAR will be equal to 1:1, which means that the DAR should be equal to the ratio of the video resolution.

查看更多
我想做一个坏孩纸
3楼-- · 2020-02-24 02:02

ffprobe is preferable for getting media information. When using ffmpeg -i file and no other arguments, ffmpeg returns an error status.

查看更多
登录 后发表回答