Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting video information from MediaInfo

Tags:

bash

shell

video

To get the dimensions of a file, I can do:

$ mediainfo '--Inform=Video;%Width%x%Height%' ~/Desktop/lawandorder.mov
1920x1080

However, if I give a url instead of a file, it returns None:

$ mediainfo '--Inform=Url;%Width%x%Height%' 'http://url/lawandorder.mov'
(none)

How would I correctly pass a url to MediaInfo?

like image 341
David542 Avatar asked Sep 11 '11 05:09

David542


2 Answers

You can also use curl | head to partially download the file before running mediainfo.

Here's an example of getting the dimensions of a 12 MB file from the web, where only a small portion (less than 10 KB) from the start needs to be downloaded:

curl --silent http://www.jhepple.com/support/SampleMovies/MPEG-2.mpg \
  | head --bytes 10K > temp.mpg
mediainfo '--Inform=Video;%Width%x%Height%' temp.mpg
like image 173
Dan Cecile Avatar answered Oct 28 '22 15:10

Dan Cecile


To do this, I needed to re-compile from source using '--with-libcurl' option.

$ ./CLI_Compile.sh --with-libcurl
$ cd MediaInfo/Project/GNU/CLI
$ make install

Then I used this command to get video dimensions via http:

$ mediainfo '--Inform=Video;%Width%x%Height%' 'http://url/lawandorder.mov'

Note, this took a considerable amount of time to return the results. I'd recommend using ffmpeg if the file is not local.

like image 22
David542 Avatar answered Oct 28 '22 16:10

David542