How to get aspect ratio from a video file?

How to get aspect ratio from a video file? (For example, 16: 9 or 4: 3)?

+4
source share
2 answers

Install the mediainfo tool. Run it with mediainfo -f --Output=XML <file> to test it.

PS: In my case (openSUSE, mediainfo 0.7.34 the --Output option was ignored).

+4
source

You can use ffmpeg for this:

 my ($aspect) = `ffmpeg -i filename.mov 2>&1` =~ /DAR\s*(\d+:\d+)/; 

Or ffprobe :

 my ($aspect) = `ffprobe -i filename.mov -show_streams 2>&1` =~ /display_aspect_ratio=(.+)/; 
+4
source

Source: https://habr.com/ru/post/1380176/


All Articles