From 06bac9f1e1e3d6dd9da332822f7f08357dd6a316 Mon Sep 17 00:00:00 2001 From: TheTroll Date: Thu, 1 Apr 2010 19:35:55 +0200 Subject: Improved encoding start Recordings are still failing --- bin/istream.sh | 19 +++++++++++++------ bin/session.php | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/bin/istream.sh b/bin/istream.sh index 88508d6..d9bb2a5 100755 --- a/bin/istream.sh +++ b/bin/istream.sh @@ -12,6 +12,7 @@ FFPATH=$7 SEGMENTERPATH=$8 SESSION=${9} FFMPEGLOG=${10} +FFMPEGPREFIX=${11} if [ $# -eq 0 ] then @@ -42,22 +43,28 @@ cd ../ram/$SESSION # Create a fifo 2>/dev/null mkfifo ./fifo -#(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 \ +(trap "rm -f ./ffmpeg.pid; rm -f ./fifo" EXIT HUP INT TERM ABRT; \ + $FFMPEGPREFIX $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 > ./fifo) & + -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 30 -async 2 -threads 4 - 2>$FFMPEGLOG >./fifo) & # Store ffmpeg pid PID=$! -2>/dev/null echo `\ps ax --format pid,ppid | grep "$PID$" | awk {'print $1'}` > ./ffmpeg.pid +if [ ! -z "$PID" ] +then + 2>/dev/null echo `\ps ax --format pid,ppid | grep "$PID$" | awk {'print $1'}` > ./ffmpeg.pid +fi # 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 PID=$! -2>/dev/null echo `\ps ax --format pid,ppid | grep "$PID$" | awk {'print $1'}` > ./segmenter.pid +if [ ! -z "$PID" ] +then + 2>/dev/null echo `\ps ax --format pid,ppid | grep "$PID$" | awk {'print $1'}` > ./segmenter.pid +fi + diff --git a/bin/session.php b/bin/session.php index 37aade9..81582ee 100644 --- a/bin/session.php +++ b/bin/session.php @@ -82,13 +82,13 @@ function sessioncreate($type, $url, $mode) switch ($type) { case 'tv': - $cmd = "./istream.sh \"" .$url ."\" " .$qparams ." " .$httppath ." 2 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \"" .$ffdbg ."\" >/dev/null &"; + $cmd = "./istream.sh \"" .$url ."\" " .$qparams ." " .$httppath ." 2 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \"" .$ffdbg ."\" \"\" >/dev/null &"; break; case 'rec': - $cmd = "cat \"" .$url ."\"/0* | ./istream.sh - " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \"" .$ffdbg ."\" >/dev/null &"; + $cmd = "./istream.sh - " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \"" .$ffdbg ."\" \"cat \\\"" .$url ."/\\\"/0* |\" >/dev/null &"; break; case 'vid': - $cmd = "./istream.sh \"" .$url ."\" " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \"" .$ffdbg ."\" >/dev/null &"; + $cmd = "./istream.sh \"" .$url ."\" " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \"" .$ffdbg ."\" \"\" >/dev/null &"; break; default: $cmd = ""; @@ -259,13 +259,20 @@ function getstreamingstatus($session) $status['message'] .= "
"; + + $status['message'] .= "
* FFmpeg: "; + if (file_exists($path .'/ffmpeg.pid')) + $status['message'] .= "running"; + else + $status['message'] .= "stopped"; $status['message'] .= "
* Segmenter: "; if (file_exists($path .'/segmenter.pid')) - $status['message'] .= "running"; + { + $status['message'] .= "running ("; + $status['message'] .= count(glob($path . '/*.ts')) ."/2)"; + } else $status['message'] .= "stopped"; - $status['message'] .= "
* Segments: "; - $status['message'] .= count(glob($path . '/*.ts')) ."/2"; } } -- cgit v1.2.3