3

I am looking for a tool or group of tools that combined can read recursively from a folder and output the Name of the folder, name of the movie file, resolution of movie and other info.

For example, an output of it would be:

(1997) Titanic, Titanicmovie, 1280x720, 720p  
(2001) Matrix 2, Matrix2, 1280x1080, 1080p  
(2012) Titan, Titanmovie, 1280x720, 720p
3
  • Do remember that the syntax could be a bit different. It can always be awk'd or grep'd into place.
    – nanofarad
    Sep 18, 2012 at 21:37
  • @ObsessiveFOSS - Yeah I figured that the use of them would be needed, not if I just had a problem that could look into a video format file and tell me this info, then I could play with bash to create a script for it. Sep 18, 2012 at 22:35
  • Did small script below that does it now. Sep 27, 2012 at 17:13

2 Answers 2

5

awk & grep + exiftool

http://www.sno.phy.queensu.ca/~phil/exiftool/

should be able to get everything you need info wise.

mp4:

$ exiftool big_buck_bunny_480p_surround-fix.avi 
ExifTool Version Number         : 9.02
File Name                       : big_buck_bunny_480p_surround-fix.avi
Directory                       : .
File Size                       : 210 MB
File Modification Date/Time     : 2012:09:19 09:43:12-04:00
File Access Date/Time           : 2012:09:19 09:43:22-04:00
File Permissions                : rw-rw-r--
File Type                       : AVI
MIME Type                       : video/x-msvideo
Frame Rate                      : 24
Max Data Rate                   : 0 kB/s
Frame Count                     : 14315
Stream Count                    : 2
Stream Type                     : Video
Video Codec                     : FMP4
Video Frame Rate                : 24
Video Frame Count               : 14315
Quality                         : 0
Sample Size                     : Variable
Image Width                     : 854
Image Height                    : 480
Planes                          : 1
Bit Depth                       : 24
Compression                     : FMP4
Image Length                    : 1229760
Pixels Per Meter X              : 0
Pixels Per Meter Y              : 0
Num Colors                      : Use BitDepth
Num Important Colors            : All
Audio Codec                     : 
Audio Sample Rate               : 56000
Audio Sample Count              : 33401088
Encoding                        : FAST Multimedia DVM
Num Channels                    : 6
Sample Rate                     : 48000
Avg Bytes Per Sec               : 56000
Bits Per Sample                 : 16
Duration                        : 0:09:56
Image Size                      : 854x480

mkv

   $ exiftool hddvd_demo_1080p.mkv 
ExifTool Version Number         : 9.02
File Name                       : hddvd_demo_1080p.mkv
Directory                       : .
File Size                       : 278 MB
File Modification Date/Time     : 2012:09:19 10:09:51-04:00
File Access Date/Time           : 2012:09:19 10:08:43-04:00
File Permissions                : rw-rw-r--
File Type                       : MKV
MIME Type                       : video/x-matroska
Doc Type                        : matroska
Doc Type Version                : 1
Doc Type Read Version           : 1
Timecode Scale                  : 1 ms
Muxing App                      : libebml v0.7.7 + libmatroska v0.8.1
Writing App                     : mkvmerge v2.0.2 ('You're My Flame') built on Feb 21 2007 23:40:55
Duration                        : 0:02:01
Date/Time Original              : 2007:04:07 03:28:47Z
Video Codec ID                  : V_MS/VFW/FOURCC
Image Width                     : 1920
Image Height                    : 1080
Video Scan Type                 : Progressive
Display Width                   : 1920
Display Height                  : 1080
Default Duration                : 32 ms
Track Number                    : 3
Track Type                      : Audio
Track Used                      : Yes
Track Default                   : No
Track Forced                    : No
Track Timecode Scale            : 1
Audio Codec ID                  : A_EAC3
Codec Decode All                : Yes
Track Language                  : eng
Track Name                      : Dolby Digital Plus 5.1 640kbps
Audio Sample Rate               : 48000
Audio Channels                  : 6
Image Size                      : 1920x1080

So what you could do is something along the lines of

find . -name "*.ogg" -o -name "*.avi" -exec exiftool {} \;

adding

-o -name "*.videoFormat"

for each additional video format. Also this is just a base to get you started. You could also do

exiftool ~/Videos

and it will print out one giant sheet of info for each file. You will want to dump it to a file and then you can grep and awk accordingly. Hope that helps.

5
  • working on it. Trying to figure out an additional way to do an imdb lookup for missing info, like year of release.
    – Nate
    Sep 19, 2012 at 12:03
  • Ok it seems the imdb lookup tool isn't the greatest.
    – Nate
    Sep 19, 2012 at 14:10
  • Will griffith.cc do what you want?
    – Nate
    Sep 19, 2012 at 14:18
  • Not sure how exactly, since I have yet to install it. But it looks like it adds all your videos into a library of sorts and from there you can export the list to a few different formats. Download it and give it a whirl.
    – Nate
    Sep 19, 2012 at 16:15
  • Well that's a bummer. Could not find a way to do a mass import unless you were coming from another system. gcstar.org is in the ubuntu store and you can do a folder import. Can do a lookup for everything as well, as you import it.
    – Nate
    Sep 19, 2012 at 17:32
1

Movie List Script

UPDATE: Another update so that, when folder variable changes amount of directory depth, the movie titles do not get lost in the process when using cut command.

#!/bin/bash
####################################################################
# Movie List Creator Script by Luis Alvarado
# Creates File with Movie Name, Resolution, File Type & Quality
# CONFIG Variables

# FOLDER Variable is where all your movies are
# NOTE: The name of the movies is extracted from the movie's folder,
#       if the folder is called "..Movies/The Rabbit"
#   the name of the movie in that folder will be "The Rabbit".

folder="/media/cyrex/xtreme/Movies"

# FINAL Variable is the name of the file you wish to create with the
# Movie List.

final="moviefinal.txt"

####################################################################

here=$(pwd)

clear
echo "Processing Movies..."
echo ""
percent=$(ls $folder/|wc -l| while read pipe; do echo "scale=3; 100/$pipe"; done|bc)
movies=1
rm tempmovies 2> /dev/null
for dir in $folder/*
do
  (cd "$dir" && found=$(pwd) && echo ${found##/*/} |tr -s '\n' ', ' >> $here/tempmovies &&
  exiftool -ext .mkv -ext .m4v -ext .mp4 -ext .avi -ext .mpg * -t -s3 -ImageSize -FileType|tr -s '\t' ',' >> $here/tempmovies )
    base=$(echo "scale=3; $percent * $movies" | bc)
    echo -ne " Total: $base% Done / $movies Movies Added!"\\r
    let movies=movies+1
done

echo " "
echo " Detecting Movie Quality..."
echo " "

rm $final 2> /dev/null
cat tempmovies | while read MovieName;
do
    echo "$MovieName" | cut -d ',' -f2 | cut -d 'x' -f2 | sort | uniq | while read MovieRes;
    do
        if (($MovieRes>=304 && $MovieRes<=370))
                then
                        echo "$MovieName,LOW-RES DVD"
        elif (($MovieRes>=241 && $MovieRes<=369))
        then
            echo "$MovieName,HI-RES DVD"
        elif (($MovieRes>=371 && $MovieRes<=479))
        then
            echo "$MovieName, EDTV 480p"
        elif (($MovieRes>=480 && $MovieRes<=760))
        then
            echo "$MovieName, HDTV 720p"
        elif (($MovieRes>=761 && $MovieRes<=1200))
        then
            echo "$MovieName, HDTV 1080p"
        else
            echo "$MovieName,VCD"
        fi >> $final
    done
done

echo " "
echo "Summary: "
echo "----------------"
cat $final | cut -d ',' -f4| sort | uniq -c
echo "----------------"
echo " "
rm tempmovies 2> /dev/null
echo "File $final Created!"

For the script to work we first need to install the exiftool found in the package libimage-exiftool-perl. So a quick sudo apt-get install libimage-exiftool-perl will do.

The script needs to be run outside the movie folder that holds all movies (If you leave it as it is). It will gather all movie titles assuming the title is the name of the folder, it will gather format and resolution from the video assuming you only have video files inside the movie folder (Subtitles for example should not be there). Lastly it will give an approximate of the quality, if the video is 720p, 1080p, etc...

In another note, for some reason movies made with handbrake with M4V format are not read correctly and throw the "Large File Support" warning. To overcome this, save the file as MKV. If you already have a M4V, then use the MKVMergeGUI which does the change in less time than Handbrake. After that, exiftool should be able to read the metadata correctly.

4
  • Maybe instead of exiftool use midentify? jorgenmodin.net/index_html/archive/2010/01/04/…
    – Nate
    Sep 19, 2012 at 20:34
  • Still only says the height/width, not the "HD Quality" in a single value. For example, 1280x721 is actually a 720p and also 1200x719. So if I try to get only the height I would end up with around 72 types. Sep 19, 2012 at 20:57
  • Yeah, it looks like you could do a range, like if it is greater than 715 but less than 725 its 720. anywho, good luck.
    – Nate
    Sep 20, 2012 at 12:28
  • Finished. Now it does everything AND it can be used in any directory. Sep 28, 2012 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.