Monday, July 9, 2012

Cutting Credits with EDL in XBMC

MythTV has been serving me wonderfully for years. It's an incredible system and is still my primary media solution to this day. Unfortunately, the tools provided for managing video metadata have fallen a little behind. I recently switch away from Boxee and gave XBMC a try. What a fantastic front end and the media management tools are perfect.

My wife and I watch Star Trek Voyager each night to fall asleep (I hear you snickering). A minor frustration is that I have to fast forward through the intro credits, and I also have to exit out at the end, select the next episode and then get through those intro credits in a few minutes. It's a really minor annoyance but one I am proud to say I have overcome with the build-in EDL (edit decision lists) that are supported by XBMC. EDL is a file type that informs XMBC to skip or mute a particular section of a video. The file format is pretty simple, each line has the start time in seconds, end time in seconds and then a numeric representation of what to do (skip 0, mute 1). The problem is creating these files can be a bit of a pain. I simplified the process with a small batch file, mplayer and NotePad++ (you can use regular notepad).

[codesyntax lang="bash"]
@ECHO OFF
set str=%1
for /f "useback tokens=*" %%a in ('%str%') do set str=%%~a
"C:Program Files (x86)SMPlayermplayermplayer.exe" %1.avi -edlout %1.edl
"C:Program Files (x86)SMPlayermplayermplayer.exe" -frames 0 -identify %1.avi | find "ID_LENGTH"
"C:Program Files (x86)Notepad++notepad++.exe" "%str%.edl"
[/codesyntax]

The only tool you really need is MPlayer (free). Once you have mplayer installed and the proper paths reflected in the batch file, The workflow is:

  1. Go to a command prompt in the folder containing the above batch file and execute: edl.bat "M:STVSeason 2Star Trek Voyager S02E25" (notice the lack of extension)

  2. Navigate to the beginning of the intro credits and press i.

  3. Navigate to the end of the intro credits and press i again.

  4. Navigate to the beginning of the ending credits and press i.

  5. Press i again and then q.

  6. The script will determine the total length of the video and print it on the command line, it will then launch your text editor and open the edl file

  7. Change the second to last number on the last line to match the total length.

  8. Save the edl and close it

  9. Repeat for all of the video files you want to edit.


MPlayer has pretty easy navigation controls. PgUp for forward 10-min, up-arrow forward 1 min, right arrow forward 10-sec. I can create an EDL in about 30-seconds.

This process can be used to remove or mute any part of a file. Finally, just use the XMBC "Play from here..." context item and you can have continuous play of the entire series without any interruption.

5 comments:

  1. Hello Jim,
    how many voyager episodes did you already cover with your EDL files? Could you make those available for download? Do you know of any edl file database on the web?

    I would also be interested in EDL files for star trek TNG.

    ReplyDelete
  2. I have all 7 seasons. Here is the EDL set in tar.gz - https://dl.dropboxusercontent.com/u/3153370/Star%20Trek%20Voyager%20EDL.tar.gz. I'd love the EDL for TNG if you complete it!

    ReplyDelete
  3. thats great. thank you very much. must have been lots of work.
    Did you create EDL files for any other series?

    ReplyDelete
  4. It's not actually all that hard, all in all it was about 2-hours of work for all 7 seasons. The problem is that you have to be focused and you really really get tired of hearing the intro music :)

    Did they work correctly for you? I wonder how well they translate since I transcoded them a long time ago.

    I only did Voyager but let me know if you get any other shows EDL'd and I'll add them here as well until we can find a permanent home.

    ReplyDelete
  5. I had the idea to use the chapter markers on DVDs for easy locating the credit/intro positions. I noticed that chapter 2 of every TNG episode always starts exactly after the intro, and the last chapter always starts with the beginning of the credits. So I developed a small PHP script, which makes use of mkvinfo tool to extract the chapter data from MKV files and writes the EDL files from that. Works quite well so far. You just have to specify the duration of the intro for every season (seems to vary a bit between seasons). This of course only works if chapter data is available.

    Another approach could be the command line tool comskip (http://www.kaashoek.com/comskip/). Its designed to skip commercials in tv caps, but could probably as well be used to locate intro and credits in episodes. I found it too hard to deal with so I gave up.

    ReplyDelete