Warning: include(/home/content/j/e/f/jeffschiller/html/log.php) [function.include]: failed to open stream: No such file or directory in /home/content/68/6293468/html/blog/wp-content/themes/cd2010/header.php on line 9

Warning: include() [function.include]: Failed opening '/home/content/j/e/f/jeffschiller/html/log.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/content/68/6293468/html/blog/wp-content/themes/cd2010/header.php on line 9
Setting Up MythVideo For Playlists | CodeDread Blog

I have a bunch of cartoons and film shorts on my hard drive. Now that I’ve installed Suse, I have video/audio output to my TV/Stereo, and I’ve set up Myth, I wanted to figure out how to play a series of videos from a playlists (.pls) file. Here’s how I did it. As a bonus, I also set up Myth with an option to randomize a playlist as well.

MythVideo uses MPlayer to play its videos. The command-line option for MPlayer to play a M3U playlist is -playlist <file.pls>. The trick here is to convince MythVideo to invoke MPlayer with this option when referencing a playlist file.

Step By Step

  • Bring up the Myth front-end (run “mythfrontend&”)
  • Navigate to Setup > Videos Settings > File Types:
  • Select the “New” button
  • Enter “pls” as the new extension and select the “Create new extension” button
  • Navigate to the Command box and type in “mplayer -fs -playlist %s”. Make sure you uncheck the “Use default player” checkbox
  • Select the “Done” button

Now escape back to the Myth home menu and go to “Videos”, select “Video List” and find a playlist file (this is a plain text file that has one video listed per line and ends in .pls). Once it’s selected, your playlist should start playing in order.

This thing is kind of nice if you’re a movie-goer freak and, for instance, want to set up a “movie night” such that a cartoon and/or comedy short is played before the “main feature”. It would also be worthwhile if you’re into music videos or maybe you want to watch all the Lost or Twin Peaks episodes in chronological order without ever having to touch your remote/keyboard/mouse. By the way, to skip ahead one video file, press the “>” key (on my keyboard I have to press Shift and the period key to do this),

Shuffling A Video Playlist

Now I wanted to take this a step further and actually randomize the playlist every time it plays.

A ways back, I wrote a quick awk script to shuffle a playlist file. Nothing fancy or terribly efficient, but it works:

#!/usr/bin/gawk -f
num_records = 0;
indices[num_records] = num_records;
records[num_records] = $0;
for(ind = 0; ind < num_records; ++ind) {
swap = int(rand() * num_records)
temp = indices[ind]
indices[ind] = indices[swap]
indices[swap] = temp
for(ind = 0; ind < num_records; ++ind) {
printf records[indices[ind]] “\n”;

Save the above file as /usr/bin/shuffle and ensure it has executable permissions (“chmod +x shuffle”). You’ll need to be root for that.

So to make a playlist that shuffles every time before playing, I followed the same Myth directions I gave above but I created a new File type (“.spl” for Shuffled PlayList). This time, the Command I want MythVideo to run for a Shuffled PlayList is:

cat %s | shuffle > $$.spl ; mv $$.spl %s; mplayer -fs -playlist %s

Rename your playlists to have the .spl extension and MythVideo should randomize them every time they are played. WARNING: Backup your playlist files and use a copy if you decide to do this, since the shuffled playlist overwrites itself with every play there’s some minimal risk that a burp in the system could cause you to lose your playlist.

Update 2007-02-18: To use xine instead of MPlayer (which I now do), you have to use a slightly different command:

cat %s | shuffle > $$.spl ; mv $$.spl %s; xine -f –playlist %s

On the next page, for the curious, I’ll describe how the above works in more detail (for those interested in learning about the power of Unix).

Pages: 1 2

§315 · December 17, 2006 · Linux, Software, Technology, Tips, Video · · [Print]

3 Comments to “Setting Up MythVideo For Playlists”

  1. This is sweet. I have a bunch of short clips that I can do this with! Thanks.

  2. Patrick Domack says:

    I just use /tmp/shuffle.pl

    As each frontend is on a different system, and has it’s own /tmp filesystem no chance of them overwriting each other.

    cat %s | shuffle > /tmp/shuffle.pl; mplayer -fs -playlist shuffle.pl

  3. Tim says:

    Instead of shuffling by the script, You can also use “-shuffle” as an MPlayer option!