Get aspect ratio of video from FFmpeg
ffprobe -v error -select_streams v:0 -show_entries stream=width,height,sample_aspect_ratio,display_aspect_ratio -of json=c=1 'filepath.mov'
this command will get width, height, sar and dar of the first video stream of file in json format.
ffprobe is preferable for getting media information. When using ffmpeg -i file and no other arguments, ffmpeg returns an error status.
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.