Serving MythTV files to my wife’s laptop

This Christmas I have been running MythTV, and have been quite impressed. If we ever ditch our old Sony HDD recorder I’d set up a low power MythTV box in its place. The best feature is how it can resolve recording conflicts using the many repeat showings available.

I’ve knocked together a quick PHP script to list the programs. It also allows download. At the moment it does not allow playback. The video tag in Chrome crashes. Firefox hangs. I suspect the codec may be an issue, so I’d need to explore Myth’s transcode features to make something more suitable for connected laptops. If I use a Samba share then I can play the files on the laptop using VLC media player, but have to deal with the naming convention that Myth uses.

The quick and dirty PHP script is below. It was designed as a single file so it could be posted here, but something more complete would require separation into multiple components. The play.php mentioned does not work so has not been included. I’ve not used transcoding so do not know what that does to the files. I suspect it would require an alteration to the script. The script is installed in /var/lib/mythtv/index.php. I’ve configured Apache to serve from that directory and created a user on my MYSQL server called “mythweb” which has read only access to the database. OK, if you can do that you can probably make a file like this. The Apache changes were made in /etc/apache2/sites-enabled/000-default and the MySQL change through the graphical mysql-admin program.

<html>
<head>
<title>MythTV Server - Recorded Programs</title>
<style>
body { background: white; color: black; }
div.even, div.odd {
        width: 100%;
        margin-top: 10px;
        clear: both;
}
h2 { padding-top: 10px; margin-bottom: 0px; }
h3 { font-style: italic; margin-top: 0px; margin-bottom: 0px; }
td { vertical-align: top; }
.buttonlink { background: grey; border: solid black 1px; border-radius: 8px; padding: 6px; }
</style>
</head>
<body>
<h1>MythTV Server - Recorded Programs</h1>
<table>
<?php

$dbh = new PDO("mysql:host=localhost;dbname=mythconverg",'mythweb','mythweb');
$even = 0;
foreach($dbh->query('SELECT basename, title, subtitle, description, storagegroup FROM recorded') as $row)
{
$even = 1-$even;
if($row['storagegroup'] == 'LiveTV')
{
    $basename = "livetv/" . $row['basename'];
}
else
{
    $basename = 'recordings/' . $row['basename'];
}
?>
<tr class="<?= $even ? 'even' : 'odd' ?>">
<td><img class="thumbnail" src="<?= htmlentities($basename).'.png' ?>"></td>
<td>
        <hgroup>
        <h2><?= htmlspecialchars($row['title']) ?></h2>
        <?php if($row['subtitle']){ print '<h3>'.htmlspecialchars($row['subtitle']).'</h3>'; } ?>
        </hgroup>
        <p class="description"><?= htmlspecialchars($row['description']); ?></p>
        <p><a class="buttonlink" href="<?= htmlentities($basename) ?>">Download</a>
           <a class="buttonlink" href="play.php?id=<?= urlencode($row['basename']) ?>" target="video_screen">Play (needs HTML5)</a>
</p>
</td>
</tr>
<?php
}
?>
</table>
</body>
</html>
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *