![]() |
downloads | documentation | HowTo | reporting bugs | links | Recent Changes |
What is a Wiki?See WikiWikiWeb If you don't know how to use a wiki see the WikiHowto ErfurtWiki is maintained by a loosely knit group of developers. Quick LinksRelated sitesContactPlease submit website bugs in the BugReports Contribute!Please file any wishes on UserSuggestions. Hosted By |
Hi All, UPDATE: This HOW-TO has been updated. Most files need changes. Main updated are; This HOWTO will show you how to get on-the-fly flash streaming within mythweb working. Knoppmyth R5E50 has an older version installed but there were some typo's.
#!/bin/bash Knoppmyth R5F1 has a working older version installed. To use updated version of MythwebFlash follow as below. To use MythWebFlash, simply click on the bitmap for the TV recording you wish to view, and Prerequisitesffmpeg with SWF support. I have upgraded the version that came with Knoppmyth R5D1 but To access this externally you will need to forward ports 80, and 8090 to your knoppmyth box. /var/www/mythweb/data/serverecording Code:
#!/bin/bash
#
# * Bash script to start and monitor server for Mythwebflash
# * Date: 2007-09-03 21:00:00 +1000
# * Version: 1.05
# * Auther: BigB
# *
#
export TERM=dumb
file=$1
bitrate=$2
function create_ffserver.conf(){
rm -f /var/www/mythweb/data/ffserver.conf
echo "Port 8090
BindAddress 0.0.0.0
MaxClients 1000
MaxBandwidth 1500
CustomLog -
<Feed feed1.ffm>
#File /var/www/mythweb/data/feed1.ffm
#FileMaxSize 128K
</Feed>
" >> /var/www/mythweb/data/ffserver.conf
if [ "$bitrate" -eq "128" ]; then
echo "
<Stream flash.swf>
Feed feed1.ffm
Format swf
AudioBitRate 8
AudioChannels 1
AudioSampleRate 11025
AudioCodec mp3
VideoBitRate 96
VideoFrameRate 4
VideoSize 144x80
VideoGopSize 40
VideoCodec flv
</Stream>
" >> /var/www/mythweb/data/ffserver.conf
else
if [ "$bitrate" -eq "256" ]; then
echo "
<Stream flash.swf>
Feed feed1.ffm
Format swf
AudioBitRate 16
AudioChannels 1
AudioSampleRate 11025
AudioCodec mp3
VideoBitRate 196
VideoFrameRate 6
VideoSize 288x160
VideoGopSize 20
VideoCodec flv
</Stream>
" >> /var/www/mythweb/data/ffserver.conf
else
if [ "$bitrate" -eq "384" ]; then
echo "
<Stream flash.swf>
Feed feed1.ffm
Format swf
AudioBitRate 16
AudioChannels 1
AudioSampleRate 11025
AudioCodec mp3
VideoBitRate 300
VideoFrameRate 10
VideoSize 288x160
VideoGopSize 20
VideoCodec flv
</Stream>
" >> /var/www/mythweb/data/ffserver.conf
fi
fi
fi
echo "
<Stream stat.html>
Format status
#ACL allow localhost
#ACL allow 192.168.0.0 192.168.255.255
</Stream>
<Redirect index.html>
URL http://www.ffmpeg.org/
</Redirect>
" >> /var/www/mythweb/data/ffserver.conf
}
DIRECTORY=/myth/tv
kill -9 `cat /var/www/mythweb/data/ffmpeg.pid`
kill -9 `cat /var/www/mythweb/data/transcode.pid`
killall -s 9 ffserver
rm -f /var/www/mythweb/data/feed1.ffm
rm -f /var/www/mythweb/data/audout
rm -f /var/www/mythweb/data/vidout
create_ffserver.conf
framewidth=`/usr/bin/mplayer -vo dummy -identify $DIRECTORY/$file 2>&1 |grep -E "ID_VIDEO_WIDTH" | cut -d= -f2`
frameheight=`/usr/bin/mplayer -vo dummy -identify $DIRECTORY/$file 2>&1 |grep -E "ID_VIDEO_HEIGHT" | cut -d= -f2`
framerate=`/usr/bin/mplayer -vo dummy -identify $DIRECTORY/$file 2>&1 |grep -E "ID_VIDEO_FPS" | cut -d= -f2`
/usr/bin/ffserver -f /var/www/mythweb/data/ffserver.conf 1> /dev/null 2> /dev/null &
PID_FFSERVER=$!
echo $PID_FFSERVER > /var/www/mythweb/data/ffserver.pid
nice -n 19 /usr/bin/mythtranscode -p autodetect -i $DIRECTORY/$file -f /var/www/mythweb/data/ 2> /dev/null 1> /dev/null &
PID_TRANSCODE=$!
echo $PID_TRANSCODE > /var/www/mythweb/data/transcode.pid
#wait for fifos
WAIT_COUNT=30
while [ "$WAIT_COUNT" -gt "0" ]; do
sleep 1
if [ -e /var/www/mythweb/data/audout ] && [ -e /var/www/mythweb/data/vidout ]; then
break
else
let WAIT_COUNT=WAIT_COUNT-1
fi
done
if [ "$WAIT_COUNT" -eq "0" ]; then
kill -9 `cat /var/www/mythweb/data/transcode.pid`
killall -s 9 ffserver
rm -f /var/www/mythweb/data/audout
rm -f /var/www/mythweb/data/vidout
exit 1
fi
sleep 1
nice -n 19 /usr/bin/ffmpeg -y -f s16le -ar 48000 -ac 2 -i /var/www/mythweb/data/audout -f rawvideo -r "$framerate" -aspect 16:9 -s "$framewidth"x"$frameheight" -i /var/www/mythweb/data/vidout http://localhost:8090/feed1.ffm 2> /dev/null 1> /dev/null &
PID_FFMPEG=$!
echo $PID_FFMPEG > /var/www/mythweb/data/ffmpeg.pid
IDLE_COUNT=20
while [ "$IDLE_COUNT" -gt "0" ]; do
sleep 1
if [ "`lynx -dump http://localhost:8090/stat.html | grep -c "flash.swf"`" -lt "3" ]; then
let "IDLE_COUNT = IDLE_COUNT - 1"
else
IDLE_COUNT=2
fi
done
kill -9 `cat /var/www/mythweb/data/ffmpeg.pid`
kill -9 `cat /var/www/mythweb/data/transcode.pid`
rm -f /var/www/mythweb/data/audout
rm -f /var/www/mythweb/data/vidout
rm -f /var/www/mythweb/data/ffserver.conf
killall -s 9 ffserver
/var/www/mythweb/data/waitflash Code:
#!/bin/bash
#
# * Bash script to wait for valid flash stream Mythwebflash
# * Date: 2007-09-03 21:00:00 +1000
# * Version: 1.01
# * Auther: BigB
# *
#
IDLE_COUNT=30
while [ "$IDLE_COUNT" -gt "0" ]; do
sleep 1
if [ "`lynx -dump http://localhost:8090/stat.html | grep -c "feed1.ffm(input)"`" -gt "0" ]; then
IDLE_COUNT=0
else
let "IDLE_COUNT = IDLE_COUNT - 1"
fi
done
sleep 2
/var/www/mythweb/modules/tv/streamrecording.php Code:
<?php
/**
* Init Mythwebflash
* Date: 2006-12-06 23:50:00 +1000
* Version: 1.01
* Auther: BigB
*
/**/
// Load the class for this page
require_once tmpl_dir.'streamrecording.php';
// Exit
exit;
?>
/var/www/mythweb/modules/tv/tmpl/default/streamrecording.php Code:
<?php
/**
* Themed page for Mythwebflash
* Date: 2007-09-03 12:00:00 +1000
* Version: 1.04
* Auther: BigB
*
/**/
echo '<html>';
echo '<head>';
if(!isset($_GET['play'])){
echo '<meta http-equiv="refresh" content="1;url=';
echo $_SERVER['PHP_SELF']."?file=".$_GET['file']."&title=".$_GET['title']."&subtitle=".$_GET['subtitle']."&description=".$_GET['description']."&play=true";
echo '">';
}
echo '<title>Stream recording</title>';
echo '</head>';
echo '<body>';
// Set the desired page title
$page_title = 'MythWeb - Stream recording';
// Print the page header
require 'modules/_shared/tmpl/default/header.php';
if(!isset($_GET['file'])){
print"<br /><br /><center><strong>You can not access this page directly!</strong></center>";
die;
}
if(!isset($_GET['width'])){
$width = '300';
}
else {
$width = $_GET['width'];
}
if(!isset($_GET['title'])){
$title = 'Unknown Title';
}
else {
$title = $_GET['title'];
}
if(!isset($_GET['subtitle'])){
$subtitle = '';
}
else {
$subtitle = $_GET['subtitle'];
}
if(!isset($_GET['description'])){
$description = '';
}
else {
$description = $_GET['description'];
}
if(!isset($_GET['height'])){
$height = '220'; //accounts for toolbar at bottom
} else {
$height = $_GET['height'];
}
if(!isset($_GET['bitrate'])){
$bitrate = '128';
} else {
$bitrate = $_GET['bitrate'];
}
$toplay = $_GET['file'];
if(!isset($_GET['play'])){
system ("bash -c \"exec nohup setsid /var/www/mythweb/data/serverecording $toplay $bitrate 1> /dev/null 2> /dev/null &\"");
} else {
system ("bash -c \"exec nohup setsid /var/www/mythweb/data/waitflash 1> /dev/null 2> /dev/null \"");
}
?>
<table width="100%" border="0" cellpadding="4" cellspacing="2" class="list small">
<tr class="recorded" height="15%">
<td rowspan="3" align="center" valign="middle" height="305" width="535">
<?php
if(isset($_GET['play'])){
echo '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="530" height="300" id="flvplayer" align="middle">';
echo '<param name="movie" value="http://';
echo getenv('SERVER_NAME');
echo ':8090/flash.swf" />';
echo '<param name="quality" value="high" />';
echo '<param name="bgcolor" value="#ffffff" />';
echo '<embed src="http://';
echo getenv('SERVER_NAME');
echo ':8090/flash.swf" width="530" height="300" quality="high" bgcolor="#fffff5" name="flvplayer" align="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
echo '</object>';
}
else{
echo 'Loading, Please wait...
You need to modify /var/www/mythweb/modules/tv/tmpl/default/recorded.php Code:
if (file_exists(cache_dir.'/'.basename($show->filename).'.png')) {
list($width,$height,$type,$attr)=getimagesize(cache_dir.'/'.basename($show->filename).'.png');
$clean_desc=str_replace("\"","",$show->description);
echo '<a href="streamrecording?file='.basename($show->filename).'&title='.$show->title.'&subtitle='.$show->subtitle.'&description='.$clean_desc.'"name=\"$row\"target=\"_new\">'
.'<img id="'.$show->filename.'"src="'.root.cache_dir.'/'.str_replace('%2F','/',rawurlencode(basename($show->filename))).'.png"'.$attr.'border="0">'
.'</a>';
}
Another change around line 316, it's a php block that provides several bit rates to stream at; Code:
</tr><tr id="statusrow_<?php echo $row ?>" class="recorded">
<td nowrap colspan="<?php echo 6 + ($_SESSION['recorded_descunder']? 0 : 1) + $recgroup_cols?>"align="center">
<?php
$clean_desc=str_replace("\"","",$show->description);
echo '<p align="left">Stream: ';
echo '<a href="streamrecording?file='.basename($show->filename).'&title='.$show->title.'&subtitle='.$show->subtitle.'&description='.$clean_desc.'&bitrate=128"name=\"$row\"target=\"_new\">128kbps</a>';
echo '<a href="streamrecording?file='.basename($show->filename).'&title='.$show->title.'&subtitle='.$show->subtitle.'&description='.$clean_desc.'&bitrate=256"name=\"$row\"target=\"_new\">256kbps</a>';
echo '<a href="streamrecording?file='.basename($show->filename).'&title='.$show->title.'&subtitle='.$show->subtitle.'&description='.$clean_desc.'&bitrate=384"name=\"$row\"target=\"_new\">384kbps</a>';
?>
<span style="padding-left: 25px">
<span style="padding-right: 25px">
<?php echo t('has commflag')
?>
You also need to modify /var/www/mythweb/modules/tv/handler.php to allow the new file. Code:
// Unknown section? Use the default
if (!in_array($Path[1], array('detail', 'channel', 'search', 'movies', 'streamrecording'))
&& empty($Modules['tv']['links'][$Path[1]]))
$Path[1] = 'list';
The config file (/etc/ffserve.conf) is no longer required as it is dynamically created is /var/www/mythweb/data For interest you can connect to http://localhost:8090/stat.html for a status of the stream server. BigB. EditThisPage BackLinks PageInfo Pages like this Attachments RSS/Atom last changed on Thu Nov 1 06:58:48 2007 |
UpdatedPages· WakeOnLANRouter last changed on Sun Feb 7 05:04:09 2010· KnoppMythWiki last changed on Sat Feb 6 14:22:21 2010 · KnoppMythInstall last changed on Tue Feb 2 04:58:54 2010 · StaticIPConfig last changed on Sun Jan 24 11:02:40 2010 · LinuxTips last changed on Tue Jan 12 05:11:08 2010 · TroubleShooting last changed on Tue Jan 12 05:09:39 2010 · HowTo last changed on Tue Jan 12 05:05:53 2010 · RarFiles last changed on Sun Jan 10 06:13:35 2010 · TinnyAudioPVR150 last changed on Thu Jan 7 19:21:53 2010 · MediaMVP_LinuxHOWTO last changed on Mon Jan 4 07:23:41 2010 · StorageGroups last changed on Mon Dec 14 18:38:15 2009 · SandBox last changed on Mon Nov 30 10:04:30 2009 · NZMythConfig last changed on Fri Nov 27 01:32:05 2009 · webminhowto last changed on Wed Nov 25 16:02:59 2009 · UpgradeHowTo last changed on Tue Nov 24 00:09:52 2009 · MythVodkaHuluFixR6 last changed on Mon Nov 23 18:09:38 2009 · Change Channels with Serial Cable last changed on Sat Nov 21 06:22:23 2009 · x11vncHowTo last changed on Wed Nov 18 09:15:23 2009 · GeForce4 last changed on Sun Nov 15 06:13:50 2009 · WhatCardYouUse last changed on Thu Nov 12 22:54:17 2009 · tv_grab_au last changed on Wed Nov 11 16:58:37 2009 · kworld115HowTo last changed on Sat Nov 7 18:18:53 2009 · AutomatedBackup last changed on Mon Oct 12 11:01:34 2009 · MythBackupAndRestoreHowTo last changed on Mon Oct 12 09:59:40 2009 · HardwareAcceleratedVideo last changed on Mon Oct 5 23:03:26 2009 · RepairingMythConvergDB last changed on Thu Oct 1 18:51:12 2009 |
| sitemap | | |