I’ve been searching about how to get video dimensions (width x height) in order to put my HD movies in one folder and non-hd movies in another folder. I didn’t want to do this manually, so the best solution would be to create a bash script that would do the job for me.
To do that, the first step is to detect the video dimensions. Basically you will need mplayer in your PATH and also use the grep and sed commands. So, to get a video’s width, the command is:
This command is divided into 3 parts. The first part (green), uses mplayer to get some information about the video. The second (red) part makes use of grep to get the line related video’s width. Finally, the third part (blue), removes the unecessary labels and gets only the number of pixels of movie’s width. At the end, you will receive only an integer value which represents the movie’s width.
To the the height, the process is the same, only replacing width by height.
And that’s it. Now you have the width and height of a movie.
Popularity: 21% [?]



