Okay, now is time to see some command line tools to analysis videos. I selected 4 Open-Source applications (avprobe, mediainfo, mplayer, exiftool).
Specification
- docker
- git
Get ready for docker images
On Bitbucket I created a repository with needed Dockerfiles for fast usage. You can also choose the installation method.
# change directory (optional) $ cd ~/Projects/ # clone repository $ git clone https://bitbucket.org/Lupin3000/tinydockerapps ~/Projects/tinydockerapps # change directory $ cd ~/Projects/VideoTest/ # build docker image for mediainfo $ docker build -t debian/mediainfo ~/Projects/tinydockerapps/mediainfo/ # build docker image for mplayer $ docker build -t debian/mplayer ~/Projects/tinydockerapps/mplayer/ # build docker image for exiftool $ docker build -t debian/exiftool ~/Projects/tinydockerapps/exiftool/ # build docker image for avprobe $ docker build -t debian/avprobe ~/Projects/tinydockerapps/avprobe/ # check available images (optional) $ docker images
mediainfo
Lets start with mediainfo. Here some information about on wikipedia.
# list help $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo --help # run simple scan $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo demo.mp4 # run full scan $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo -f demo.mp4 # show aspect ratio $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo --Inform="Video;%DisplayAspectRatio%" demo.mp4 # show duration $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo --Inform="General;%Duration/String3%" demo.mp4 # show audio format $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo --Inform="Audio;%Format%" demo.mp4 # show resolution and codec $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo --Inform="Video;Resolution=%Width%x%Height%\nCodec=%CodecID%" demo.mp4 # list all possible file parameters $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo --info-parameters | less # create XML report (all internal tags) $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo -f --Output=XML demo.mp4 # show mediatrace info $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo --Details=1 demo.mp4 # create report file $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mediainfo demo.mp4 --LogFile="Report.log"
mplayer
Second application is mplayer. Here the wikipedia link.
# list help $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mplayer --help # show all properties $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mplayer -vo null -ao null -frames 0 -identify demo.mp4 # show all video properties $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mplayer -vo null -ao null -frames 0 -identify demo.mp4 | grep VIDEO # show all audio properties $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mplayer -vo null -ao null -frames 0 -identify demo.mp4 | grep AUDIO # show video format $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/mplayer -vo null -ao null -frames 0 -identify demo.mp4 | grep ID_VIDEO_FORMAT
exiftool
Now we take a look on exiftool. Here the wikipedia article and the official documentation.
# show all parameters $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/exiftool demo.mp4 # show all parameters sort by group (including duplicate and unknown tags) $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/exiftool -a -u -g1 demo.mp4 # show friendly parameters $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/exiftool -s -G demo.mp4 # show Height and Width $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/exiftool '-*source*image*' demo.mp4 # show audio format $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/exiftool '-*Audio*Format*' demo.mp4 # show video duration $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/exiftool '-*Duration*' demo.mp4 | head -1 # create json output with specific values $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/exiftool -j -VideoFrameRate -MediaDuration demo.mp4 > report.json # create csv report file with specific values $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/exiftool -csv -FileSize -ImageWidth -ImageHeight -AudioFormat -AudioChannels demo.mp4 > report.csv
avprobe
Last but not least avprobe. Here the wikipedia article and detailed official documentation.
# list help $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/avprobe --help # list available formats $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/avprobe -formats # list available codecs $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/avprobe -codecs # show all properties $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/avprobe demo.mp4 # show stream properties in json format $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/avprobe -of json -loglevel quiet -show_streams demo.mp4 # show specific properties $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/avprobe -show_format -show_streams -pretty demo.mp4 # show size properties $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/avprobe -show_entries format=size demo.mp4 # show duration and size properties $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/avprobe -loglevel quiet -show_entries format=duration,size demo.mp4 # show duration and size properties in json format $ docker run --rm -i -v ~/Projects/VideoTest/:/mnt debian/avprobe -of json -loglevel quiet -show_entries format=duration,size demo.mp4
Compare tools by expecting specific result
I will not judge the applications against each other! But here a compare of complexity of commands and output for video duration.
# get duration by exiftool $ exiftool -s -s -s -MediaDuration demo.mp4 ... 0:01:04 # get duration by mediainfo $ mediainfo --Inform="General;%Duration/String3%" demo.mp4 ... 00:01:04.884 # get duration by avprobe $ avprobe -v error -sexagesimal -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 demo.mp4 ... 0:01:04.884000 # get duration by mplayer $ mplayer -vo null -ao null -frames 0 -nolirc -identify demo.mp4 | grep ID_LENGTH | cut -d'=' -f2 ... 64.88