Mythtv/Plugins/MythTube

Hello Everybody,

I have created a userjob and webpage to play Myth videos in a browser over the internet. I call it MythTube. It's very simple to setup and plays video great. Each flash video is about 80M for an hour long show (minus commercials). It consists of a php page, a transcode script, and a flash player. I run the transcode job after the remove commercials script from the Wiki. The remove commercials may be important as I saw comments about B-Frames being a problem with mencoder. I believe lossless transcoding removes any B-Frames.

To setup Mythtube, first create a directory under your webserver called mythtube. Mine was "/data/www/html/mythtube". You will need to change any references below to whatever your directory is.

Next, get flvplayer.swf. Download http://www.jeroenwijering.com/upload/flash_flv_player.zip and move flash_flv_player/extras/flvplayer.swf into your mythtube directory under your webserver.

Then create "play.php" and put it in the mythtube directory as well. Here's play.php: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN"> Welcome to MythTube!  Now playing:  " height="" wmode="transparent" data="flvplayer.swf?file="> " />  Videos:

Next you need to create the userjob which generates the flv files.

Here's the MYSQL commands I used in creating userjob 3: use mythconverg;

UPDATE settings SET data='/usr/local/bin/flashtranscode %DIR% %FILE% "%TITLE%" %STARTTIME%' WHERE value='UserJob3';

UPDATE settings SET data='Flash Transcode' WHERE value='UserJobDesc3';

UPDATE settings SET data='1' WHERE value='JobAllowUserJob3';

Here's the /usr/local/bin/flashtranscode script: # VIDEODIR=$1 FILENAME=$2 TITLE=$3 TITLE=${TITLE//[^a-zA-Z0-9]/} STARTTIME=$4 if [ -z "$VIDEODIR" -o -z "$FILENAME" ]; then echo "Usage: $0   "" " exit 5 fi if [ ! -f $VIDEODIR/$FILENAME ]; then echo "File does not exist: $VIDEODIR/$FILENAME" exit 6 fi mencoder -ofps 12 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -oac lavc -lavcopts acodec=mp3:abitrate=32 -channels 1 -srate 22050 -ovc lavc -lavcopts vcodec=flv:vbitrate=200:cbp:mv0:mbd=2:trell:v4mv:predia=2:dia=2:last_pred=3 -vop spp,scale=360:240,harddup -o /data/www/html/mythtube/$TITLE-$STARTTIME.flv $VIDEODIR/$FILENAME i_certify_that_my_video_stream_does_not_use_b_frames -oac lavc -lavcopts acodec=mp3:abitrate=32 -channels 1 -srate 22050 -ovc lavc -lavcopts vcodec=flv:vbitrate=100:mbd=2:mv0:trell:v4mv:cbp:last_pred=3:predia=2:dia=2:vmax_b_frames=0:vb_strategy=1:precmp=2:cmp=2:subcmp=2:preme=2:qns=2 -vop spp,scale=320:240 -o /data/www/html/mythtube/$TITLE-$STARTTIME-2.flv $VIDEODIR/$FILENAME ERROR=$? if [ $ERROR -ne 0 ]; then echo "Transcoding failed for ${FILENAME} with error $ERROR" exit 3 fi
 * 1) !/bin/sh
 * 2) flashtranscode
 * 1) created by Jeff Volckaert (inspired by Zach White)
 * 2) modified 11/03/06 to use Flash
 * 1) Remove non-alpha characters from TITLE
 * 1) Sanity checking, to make sure everything is in order.
 * 1) Transcode the file
 * 1) For a smaller file use this instead.
 * 2) (It take three times longer to encode though)
 * 3) mencoder -ofps 12 -of lavf -lavfopts
 * 1) Uncomment this if you want to insert MetaData tags into the file
 * 2) /usr/bin/flvtool2/flvtool2 -U /data/www/html/mythtube/$TITLE-$STARTTIME.flv

After at least one file has been transcoded you can pull up the play.php page and start watching video.