summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-02-26 16:31:24 +0100
committerTheTroll <trolldev@gmail.com>2010-02-26 16:31:24 +0100
commitc904edb8d3cb6f03942ba9a65ee7f0ef5646493c (patch)
tree2ef911a28a7532e67fae2b1ac2776c9df5bc6b84
parent39c1ca8f367d9fa60ab02542abcdc2b7dee5b556 (diff)
downloadistreamdev-c904edb8d3cb6f03942ba9a65ee7f0ef5646493c.tar.gz
istreamdev-c904edb8d3cb6f03942ba9a65ee7f0ef5646493c.tar.bz2
Now kill segmenter using its PID
-rwxr-xr-xincludes/include.php17
-rwxr-xr-xistream.sh11
2 files changed, 19 insertions, 9 deletions
diff --git a/includes/include.php b/includes/include.php
index 8045ab1..38a91b8 100755
--- a/includes/include.php
+++ b/includes/include.php
@@ -17,7 +17,20 @@ function selectpage()
if ($action == "stopstream")
{
- $cmd= "killall segmenter && killall -9 ffmpeg ; rm ram/stream*";
+ $subcmd = "";
+
+ // Get segmenter PID
+ $pidfile = fopen('ram/streamsegmenterpid', 'r');
+ if ($pidfile)
+ {
+ $pid = fgets($pidfile);
+ $pid = substr($pid, 0, -1);
+ $subcmd = "kill " .$pid ." ; ";
+ fclose($pidfile);
+ }
+
+ $cmd= $subcmd ."rm ram/stream*";
+ print $cmd;
exec ($cmd);
$action = $_REQUEST['actionafterstop'];
@@ -115,7 +128,7 @@ function start_stream($type, $name, $title, $desc, $qname, $qparams, $category,
}
$cmd = str_replace('%', '%%', $cmd);
- exec ($cmd);
+ exec($cmd);
// Write streaminfo
writeinfostream($type, $name, $title, $desc, $qname, $category, $url, $mediapath, $subdir);
diff --git a/istream.sh b/istream.sh
index ae32bb0..e64b9ea 100755
--- a/istream.sh
+++ b/istream.sh
@@ -12,8 +12,6 @@ SEGWIN=$7 # Amount of Segments to produce
FFPATH=$8
SEGMENTERPATH=$9
-PREFIX=stream
-
if [ $# -eq 0 ]
then
echo "Format is : ./istream.sh source video_rate audio_rate audio_channels 480x320 httppath segments_number ffmpeg_path segmenter_path"
@@ -26,17 +24,16 @@ fi
# sending it to the segmenter via a PIPE
##############################################################
-if (! ps ax | awk '{print $5}' | grep -q "$SEGMENTERPATH")
-then
test -L ram && (test -d /dev/shm/ram || mkdir /dev/shm/ram)
cd ram
-2> /dev/null rm "$PREFIX"*.ts
+2> /dev/null rm stream*.ts
2> /dev/null $FFPATH -i "$STREAM" -deinterlace -f mpegts -acodec libmp3lame -ab $ARATE -ac $ACHANNELS -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 - | \
-$SEGMENTERPATH - $SEGDUR $PREFIX $PREFIX.m3u8 $HTTP_PATH $SEGWIN &
+$SEGMENTERPATH - $SEGDUR stream stream.m3u8 $HTTP_PATH $SEGWIN &
-fi
+// Save segmenterpid
+echo "$!" > streamsegmenterpid