IMDB Film Summary as a MPEG2 video

If you’ve read my blog before you’ll know I run Mediatomb DLNA server with my PS3 as the client, You’ll also know I am working towards importing my entire DVD collection into my Mediatomb server. However, my wife wants to know something about each film in the library without having to dig out the DVD case from storage. My solution is to include a MPEG-2 video displaying the film summary in the Mediatomb library for each DVD I have imported so it can be easily viewed from the PS3.

My script is called IMDB-to-MPEG and I’ve finally got round to uploading it. See the Code section of my site for the download.

The scripts takes one parameter as input, a film title. The plotline, year of release, genres, cast list and running time for that film are gathered from IMDB and formatted as text. Here is an example.

The Usual Suspects (1995)

A boat has been destroyed, criminals are dead, and
the key to this mystery lies with the only
survivor and his twisted, convoluted story
beginning with five career crooks in a seemingly
random police lineup. (106 mins)

Starring Stephen Baldwin as Michael McManus,
Gabriel Byrne as Dean Keaton, Benicio Del Toro as
Fred Fenster, Kevin Pollak as Todd Hockney, and
Kevin Spacey as Roger 'Verbal' Kint.

Genres: Crime, Mystery, Thriller.

Rated 8.7 out of 10 from 227,964 votes.

The text is converted into an image and then encoded into a MPEG-2 video using the lowest possible bitrate/resolution that is acceptable to read when viewing on a 42″ plasma from my sofa.

Directories for each matching genre are created and also one for the IMDB rating (rounded down). The MPEG-2 is stored in the ‘All’ folder and then symlinked to the genres and rating for that film. I then copy my video into the appropriate directory in ‘All’. For example.

.
|-- All
|   `-- The_Usual_Suspects
|       `-- About_The_Usual_Suspects.mpg
|-- Genres
|   |-- Crime
|   |   `-- The_Usual_Suspects -> ../../All/The_Usual_Suspects
|   |-- Mystery
|   |   `-- The_Usual_Suspects -> ../../All/The_Usual_Suspects
|   `-- Thriller
|       `-- The_Usual_Suspects -> ../../All/The_Usual_Suspects
|-- Ratings
`-- 8
`-- The_Usual_Suspects -> ../../All/The_Usual_Suspects

This code was lashed up in a few hours, it ain’t pretty but it works for me on my Ubuntu Linux systems, maybe it’ll work for you too ;-)

Related posts

Posted on April 22, 2009 at 6:00 pm by Martin · Permalink
In: Audio & Video · Tagged with: , , , ,

11 Responses

Subscribe to comments via RSS

  1. Written by Martin
    on April 23, 2009 at 4:52 pm
    Permalink

    I released v1.1 which fixes a minor bug, see the Code section of my site for the download and details.

    http://code.flexion.org

  2. Written by Chris
    on April 24, 2009 at 11:45 am
    Permalink

    That is a pretty cool idea :)

  3. Written by Martin
    on April 24, 2009 at 2:22 pm
    Permalink

    Thanks Chris, I’m expecting that you will send me some improvements pretty soon ;-)

  4. Written by Eric
    on June 17, 2009 at 3:50 pm
    Permalink

    This is very nice. I’ve made a few changes, such as encoding the About vid into h264 directly via ffmpeg (so the ps3 can play it natively) and confirmation prompt so i could semi-automate having it go through my whole library with a bash while loop… because “Bookies” != “Cookie’s Fortune” silly IMDB… :)

    I also dropped the text size and set an offset position because it was HUUUUGE on my 46″ tv. Seriously, the text jumped off the screen, beat me up, and stole my wallet!

    Oh… and there’s a bug in texttoimage as well. The parameters are wrong on the call to imagettftext()

    Anyway, I’ll clean it up a bit more and send it back to ya. And to think i was getting ready to do this symlink tree manually..

  5. Written by Eric
    on June 17, 2009 at 10:07 pm
    Permalink

    You can delete this comment… i couldn’t find an email address for you.

    I ended up rewriting the whole thing today:

    http://www.ypass.net/downloads/IMDB-to-MPEG/IMDB-to-MPEG-v2.0.tar.gz

    You’ll need to add back in your mpeg2 creation stuff. I have no clue what you’re doing there :) .

    Look for encodeVideoM4V() and just create a encodeVideoMPEG2() or whatever, then modify the switch statement below it.

  6. [...] hand, I ran into another unrelated problem. While I was searching for the solution, I came across IMDB-to-MPEG. I had to hack around a bit in the PHP code to get it to work the way I wanted, but man did it save [...]

  7. Written by Martin
    on June 27, 2009 at 9:14 am
    Permalink

    @Eric: Thanks very much for the improvements you have made. I’ll review your code and quite possibly release a revised version in the next week or so :-)

  8. Written by Martin
    on September 20, 2009 at 8:50 am
    Permalink

    I’ve finally got round to working with Eric and incorporating all his contributions and improvements. v2.0 of IMDB-to-MPEG is now available, find out more at the URL below.

    http://blog.flexion.org/index.php/2009/09/20/imdb-film-summary-as-a-mpeg2-video-part-2/

  9. Written by Jukka
    on November 24, 2009 at 1:15 pm
    Permalink

    Great script! Unfortunately it seems that I am the only one who is not able create the summary file (mp4 or m2v) on my (k)ubuntu 9.10 machine based on your script. Even if I am using debugging mode I don’t get any errors. I believe it is related to ffmpeg part of the script so I need to study it a bit more. Do you have any hint where to look?

  10. Written by Martin
    on December 3, 2009 at 11:54 am
    Permalink

    @Jukka, I have seen this before. The encode is failing because h.264 video encoding libraries are not available to ffmpeg. On 9.04 this can be fixed by install the ‘libav*-unstripped’ libraries on 9.10 I think they are called libav*-extras’. Try the following…

    sudo aptitude install ffmpeg libavcodec-extra-52

    If that doesn’t work you can try two things. Pass the MPEG-2 flag to the script to create MPEG-2 video rather than MPEG-4, use ‘-o m2v’. See the help for more details.

    Or a more involve work around is to modify the script to use XviD rather than h.264. Find the ffmpeg line ~813. Find ‘-f mp4′ and change it to ‘-f libxvid’.

  11. Written by Jukka
    on January 14, 2010 at 2:09 pm
    Permalink

    @Martin: Just to let you know I compiled ffmpeg from source with x264 enabled. When I used this script with m4v option, the script failed due to ffmpeg presets (I don’t remember the exact error message) and no summary file was created.

    Then I changed x264 to -libxvid after which the summary movie file can be created by using the script as planned. For some reason I always get the error message that movie file is not PS3 compatible. Hopefully I have some time next week to have a more closer look on this. I will let you know if I find a way to fix this (in case someone else ran into same kind of problems).

Subscribe to comments via RSS

Leave a Reply