From c1d2407ed3e522710e41073dca391ab5375a9942 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 12 Aug 2016 10:02:15 -0400 Subject: [PATCH 1/4] add an echo to tell us that updating is done and we are trying to start. --- distros/ubuntu1604/zoneminder.postinst | 1 + 1 file changed, 1 insertion(+) diff --git a/distros/ubuntu1604/zoneminder.postinst b/distros/ubuntu1604/zoneminder.postinst index 64699d1ca..05f0c0448 100644 --- a/distros/ubuntu1604/zoneminder.postinst +++ b/distros/ubuntu1604/zoneminder.postinst @@ -41,6 +41,7 @@ if [ "$1" = "configure" ]; then deb-systemd-invoke stop zoneminder.service || exit $? zmupdate.pl --nointeractive zmupdate.pl --nointeractive -f + echo "Done Updating, starting ZoneMinder" deb-systemd-invoke start zoneminder.service || exit $? else From bdcc53d309c066999d3923afb6a2573bcdd7ef5c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 12 Aug 2016 10:04:10 -0400 Subject: [PATCH 2/4] add an echo to tell us that updating is done and we are trying to start. --- distros/debian/postinst | 1 + 1 file changed, 1 insertion(+) diff --git a/distros/debian/postinst b/distros/debian/postinst index 39e3dfc32..20f715793 100644 --- a/distros/debian/postinst +++ b/distros/debian/postinst @@ -38,6 +38,7 @@ if [ "$1" = "configure" ]; then invoke-rc.d zoneminder stop || true zmupdate.pl --nointeractive zmupdate.pl --nointeractive -f + echo "Done Updating, starting ZoneMinder" invoke-rc.d zoneminder start || true else echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.' From 1058796374fd1d248b920a5280c1e05f3d44ca29 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 12 Aug 2016 10:04:35 -0400 Subject: [PATCH 3/4] add an echo to tell us that updating is done and we are trying to start. --- distros/ubuntu1204/zoneminder.postinst | 1 + 1 file changed, 1 insertion(+) diff --git a/distros/ubuntu1204/zoneminder.postinst b/distros/ubuntu1204/zoneminder.postinst index 7c01cdde4..9d786e27d 100644 --- a/distros/ubuntu1204/zoneminder.postinst +++ b/distros/ubuntu1204/zoneminder.postinst @@ -38,6 +38,7 @@ if [ "$1" = "configure" ]; then invoke-rc.d zoneminder stop || true zmupdate.pl --nointeractive zmupdate.pl --nointeractive -f + echo "Done Updating, starting ZoneMinder" invoke-rc.d zoneminder start || true else echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.' From e74bf3fedf43e0b7e0fb926bb5ee25e6795e4f61 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 31 Aug 2016 10:58:50 -0400 Subject: [PATCH 4/4] pull in the new byte range code for viewing videos --- web/views/view_video.php | 82 +++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/web/views/view_video.php b/web/views/view_video.php index 5bf01ca6b..4e5e04c0c 100644 --- a/web/views/view_video.php +++ b/web/views/view_video.php @@ -25,36 +25,74 @@ // Does not support scaling at this time. // -if ( !canView( 'Events' ) ) -{ - $view = "error"; - return; +if ( !canView( 'Events' ) ) { + $view = "error"; + return; } -require_once('includes/Storage.php'); require_once('includes/Event.php'); - -$Storage = NULL; $errorText = false; +$path = ''; + if ( ! empty($_REQUEST['eid'] ) ) { - $Event = new Event( $_REQUEST['eid'] ); - $Storage = $Event->Storage(); - $path = $Event->Relative_Path().'/'.$Event->DefaultVideo(); - Error("Path: $path"); + $Event = new Event( $_REQUEST['eid'] ); + $path = $Event->Path().'/'.$Event->DefaultVideo(); + Debug("Path: $path"); } else { - $errorText = "No video path"; + $errorText = "No video path"; } -if ( $errorText ) - Error( $errorText ); -else{ -# FIXME guess it from the video file - header( 'Content-type: video/mp4' ); - if ( ! readfile( $Storage->Path().'/'.$path ) ) { - Error("No bytes read from ". $Storage->Path() . '/'.$path ); - } else { - Error("Success sending " . $Storage->Path().'/'.$path ); - } +if ( $errorText ) { + Error( $errorText ); + header ("HTTP/1.0 404 Not Found"); + die(); +} + +$size = filesize($path); + +$fh = @fopen($path,'rb'); +if ( ! $fh ) { + header ("HTTP/1.0 404 Not Found"); + die(); } + +$begin = 0; +$end = $size; + +if ( isset( $_SERVER['HTTP_RANGE'] ) ) { + Debug("Using Range " . $_SERVER['HTTP_RANGE'] ); + if ( preg_match( '/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches) ) { + $begin = intval( $matches[1] ); + if ( ! empty( $matches[2]) ) { + $end = intval( $matches[2] ); + } + Debug("Using Range $begin $end size: $size"); + } +} # end if HTTP_RANGE + +if ( $begin > 0 || $end < $size ) { + header('HTTP/1.0 206 Partial Content'); +} else { + header('HTTP/1.0 200 OK'); +} + +header('Content-type: video/mp4'); +header('Accept-Ranges: bytes'); +header('Content-Length:'.($end-$begin)); +header("Content-Disposition: inline;"); +header("Content-Range: bytes $begin-$end/$size"); +header("Content-Transfer-Encoding: binary\n"); +header('Connection: close'); + +$cur = $begin; +fseek( $fh, $begin, 0 ); + +while( ! feof( $fh ) && $cur < $end && ( connection_status() == 0 ) ) { + #Error("Sending $cur"); + print fread( $fh, min( 1024*16, $end - $cur ) ); + $cur += 1024*16; + usleep(100); +} + ?>