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?
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.