The other day, I wanted to find out which of the videos in my movie collection were encoded with multitrack (e.g. 5.1) sound.
I found a tool for Linux called themonospot. Happily, it’s packaged with Fedora and can be installed simply by doing
yum install themonospot-console
Once installed it’ll quickly give you information about your video files:
[jonathan@zeus ~]$ themonospot-console /media/public/Movies/Sunshine/Sunshine.avi File path: /media/public/Movies/Sunshine/Sunshine.avi Codec name: XVID Codec desc: xvid Frame size: 704 x 288 Average video bitrate: 1,423 Kb/Sec File size: 1,525,886 KB Total time: 01:47:26.00 seconds Frame rate: 24.00 frames/sec Total frames: 154,574 Video data rate: 23 frames/sec Video quality: 113 Packet Bitstream: False ISFT data: VirtualDubMod 1.5.10.2 (build 2540/release) JUNK data: VirtualDubMod build 2540/release USER data: XviD0046 Audio 01: 0x2000 (AC3) 448.00 Kb/Sec - 48000 Hz (6 Channels)
As you can see, my copy of Sunshine has 6-channel audio (i.e. 5.1). But what if you want to run a batch job to check all of your films and see which ones have surround sound?
Then use perl.
I wrote an extremely hacky script that takes a path as an argument and whizzes round to fetch the encoding of all .avi or .AVI files in the directory. It prints the names of any that have more than 2 audio channels (i.e. better than stereo).
It sometimes goes wrong if the output of themonospot-console
varies, as it occasionally does.
So you get output like this…
[jonathan@zeus ~]$ ./findAudioEncoding.pl /media/public/Movies/ /media/public/Movies/Catch Me If You Can/Catch Me If You Can.avi : 6 /media/public/Movies/National Treasure - Book of Secrets/National Treasure - Book of Secrets.avi : 6 /media/public/Movies/Never Been Kissed/Never Been Kissed.avi : 6 /media/public/Movies/Rescuers, The/Rescuers, The.avi : 5 Argument "" isn't numeric in numeric gt (>) at ./findAudioEncoding.pl line 12. /media/public/Movies/Brideshead Revisited/Brideshead Revisited.avi : 5 /media/public/Movies/Passion of the Christ, The/Passion of the Christ, The.avi : 6
If you’re interested in the source, here it is.
#!/usr/bin/perl -w # findAudioEncoding.pl use strict; my $path = $ARGV[0]; chomp (my @files = `find $path 2> /dev/null | grep -i .avi`); foreach my $file (@files) { chomp (my $channels = `themonospot-console "$file" | grep "Audio 01" | awk ' { print $10 } '`); $channels =~ s/(//g; if ($channels > 2) { print "$file : $channelsn"; } }