Stream mythtv recordings from mythweb using flash video

From MythTV Official Wiki
Revision as of 23:32, 23 February 2006 by Wiggi (talk | contribs) (Created page, added most content)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How to stream myth recordings from mythweb using flash video

Ive just setup my myth box to automatically convet everything it records into flash video which can be played in any web browser with flash 7+. The quality of the videos is more than acceptable for playing in a window on your desktop but you wouldnt want to watch a film over it. It streams straight from my PVR with no buffering issues on a 50kbps upstream connection, if you alter the settings it would work fine over a standard ADSL connection.

This guide is pretty simple to setup, but is nothing official and has no input from the developers of mythtv or mythweb. Its basically a quick hack I set up when I did a few overnights.

There are 3 stages to getting this setup:

1) Automatically transcode the files to FLV's using the user job function in myth 2) Alter mythweb to link to the recorded files and setup the flash player 3) Set the files to automatically expire.

Prerequisites:

Working MythTV, mythweb and ffmpeg.


1) Transcode recordings

First create a script as below and put it somewhere in the path of the user that runs mythbackend, eg /usr/local/bin/mythflash.sh

directory=$1;
file=$2;

ffmpeg -hq -y -i $directory/$file -r 20 -s 300x200 -deinterlace -ar 22050 $directory/$file.flv 1>/dev/null 2>/dev/null

This is a simple script which takes 2 arguments, first the folder which stores your recordings and second the file name. It then runs ffmpeg with highwuality settings, only outputting 20 frames per second, a resolution on 300x200, deinterlacing the incoming video and setting an apropriate audio sample rate and outputting the flash video file to the same dir as your recordings. You dont need to run it as a script and could just put the command in the mythtv user job field but i like it in a script to make it a little more managable.

If on a slow connection try reducing the resolution and setting the bitrate to 150 by adding -b 150 to the command.

Next you need to setup the userjob in mythtv. Run mythtv-setup and go to the General Settings section. Under user jobs find a spare job and give it a name of something apropriate (e MythFlash) and the following command:

/usr/local/bin/mythflash.sh "%DIR%" "%FILE%"

Now on the recording settings page set it to run this job, which will call the script with the correct arguments and automatically create the flash video.


2) Update mythweb

Mythweb should already be up and running on your system. cd yo tour mtyhweb directory (eg /var/www/localhost/htdocs/mythweb) and check that data/recordings is a link to the driectory which holds your recordings. If not you might have to link it manually (ln -s [your recordings dir] data/recordings

Next get hold of a copy of flvplayer.swf and put the file flvplayer.swf into your data dir, and chmod it apropriatly.

Final bit is to update the mythweb interface to link to your flash recordings. edit the file [your mythweb dir]/themes/default/tv/recorded.php and change the following (line 254):

echo '<a href="'.video_url().'/'.basename($show->filename)."\" name=\"$row\">"

to

echo '<a href="/mythweb/data/flvplayer.swf?file=/mythweb/data/recordings/'.basename($show->filename).".flv\" name=\"$row\" target=\"_new\">"

This will launch the flash player with the video in a new window when you click on the thumbnail next to a recording.