summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-04-01 14:56:15 +0200
committerTheTroll <trolldev@gmail.com>2010-04-01 14:56:15 +0200
commitf71315d724f52551980f50b446697fe6130fc451 (patch)
tree9babb5d135e8b34988b8914b7c84f00ce2079136 /bin
parent67957d8306d4975fc0bc87966abcbc47cb38a846 (diff)
downloadistreamdev-f71315d724f52551980f50b446697fe6130fc451.tar.gz
istreamdev-f71315d724f52551980f50b446697fe6130fc451.tar.bz2
Change the way we start/kill sessions
No need for a modified version of segmenter anymore
Diffstat (limited to 'bin')
-rwxr-xr-xbin/istream.sh21
-rw-r--r--bin/session.php15
2 files changed, 27 insertions, 9 deletions
diff --git a/bin/istream.sh b/bin/istream.sh
index 3476cc0..09503d3 100755
--- a/bin/istream.sh
+++ b/bin/istream.sh
@@ -33,10 +33,23 @@ fi
cd ../ram/$SESSION
-2> /dev/null rm stream*.ts
+# Create a fifo
+2>/dev/null mkfifo ./fifo
-$FFPATH -i "$STREAM" -deinterlace -f mpegts -acodec libmp3lame -ab $ARATE -ac 2 -s $XY -vcodec libx264 -b $VRATE -flags +loop \
+#(trap "rm -rf $TMP; /usr/local/bin/fw" EXIT HUP INT TERM ABRT; cat $TMP/$OUT) &
+
+# Start ffmpeg
+(trap "rm -f ./ffmpeg.pid; rm -f ./fifo" EXIT HUP INT TERM ABRT; $FFPATH -i "$STREAM" -deinterlace -f mpegts -acodec libmp3lame -ab $ARATE -ac 2 -s $XY -vcodec libx264 -b $VRATE -flags +loop \
-cmp \+chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 \
-sc_threshold 40 -i_qfactor 0.71 -bt $VRATE -maxrate $VRATE -bufsize $VRATE -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 \
- -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 30 -async 2 -threads 4 - 2>$FFMPEGLOG | \
-$SEGMENTERPATH - $SEGDUR stream stream.m3u8 $HTTP_PATH$SESSION/ $SEGWIN &
+ -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 30 -async 2 -threads 4 - 2>$FFMPEGLOG > ./fifo) &
+
+# Store ffmpeg pid
+2>/dev/null echo $! > ./ffmpeg.pid
+
+# Now start segmenter
+(trap "rm -f ./segmenter.pid" EXIT HUP INT TERM ABRT; 2>/dev/null $SEGMENTERPATH ./fifo $SEGDUR stream stream.m3u8 $HTTP_PATH$SESSION/ $SEGWIN) &
+
+# Store segmenter pid
+2>/dev/null echo $! > ./segmenter.pid
+
diff --git a/bin/session.php b/bin/session.php
index 950c855..2d63f4e 100644
--- a/bin/session.php
+++ b/bin/session.php
@@ -82,13 +82,13 @@ function sessioncreate($type, $url, $mode)
switch ($type)
{
case 'tv':
- $cmd = "export SHELL=\"/bin/sh\";printf \"./istream.sh \\\"" .$url ."\\\" " .$qparams ." " .$httppath ." 2 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \\\"" .$ffdbg ."\\\" \" | at now";
+ $cmd = "./istream.sh \"" .$url ."\" " .$qparams ." " .$httppath ." 2 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \"" .$ffdbg ."\" >/dev/null &";
break;
case 'rec':
- $cmd = "export SHELL=\"/bin/sh\";printf \"cat \\\"" .$url ."\\\"/0* | ./istream.sh - " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \\\"" .$ffdbg ."\\\" \" | at now";
+ $cmd = "cat \"" .$url ."\"/0* | ./istream.sh - " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \"" .$ffdbg ."\" >/dev/null &";
break;
case 'vid':
- $cmd = "export SHELL=\"/bin/sh\";printf \"./istream.sh \\\"" .$url ."\\\" " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \\\"" .$ffdbg ."\\\" \" | at now";
+ $cmd = "./istream.sh \"" .$url ."\" " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \"" .$ffdbg ."\" >/dev/null &";
break;
default:
$cmd = "";
@@ -194,10 +194,15 @@ function sessiondeletesingle($session)
addlog("Deleting session " .$session);
$ram = "../ram/" .$session ."/";
+ $cmd = "";
- // Get segmenter PID if any
+ // First kill ffmpeg
+ if (file_exists($ram ."ffmpeg.pid"))
+ $cmd .= " kill `cat " .$ram ."ffmpeg.pid`; rm " .$ram ."ffmpeg.pid; ";
+
+ // Then kill segmenter
if (file_exists($ram ."segmenter.pid"))
- $cmd = "/usr/local/bin/fw;kill `cat " .$ram ."segmenter.pid`; rm " .$ram ."segmenter.pid; ";
+ $cmd .= " kill `cat " .$ram ."segmenter.pid`; rm " .$ram ."segmenter.pid; ";
addlog("Sending session kill command: " .$cmd);