Merged in mpeg_encode removal
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2520 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
b2f616ff21
commit
c58b322a6e
|
@ -205,7 +205,7 @@ our @options =
|
|||
name => "ZM_COLOUR_JPEG_FILES",
|
||||
default => "yes",
|
||||
description => "Colourise greyscale JPEG files",
|
||||
help => "Cameras that capture in greyscale can write their captured images to jpeg files with a corresponding greyscale colour space. This saves a small amount of disk space over colour ones. However some tools such as ffmpeg and mpeg_encode either fail to work with this colour space or have to convert it beforehand. Setting this option to yes uses up a little more space but makes creation of MPEG files much faster.",
|
||||
help => "Cameras that capture in greyscale can write their captured images to jpeg files with a corresponding greyscale colour space. This saves a small amount of disk space over colour ones. However some tools such as ffmpeg either fail to work with this colour space or have to convert it beforehand. Setting this option to yes uses up a little more space but makes creation of MPEG files much faster.",
|
||||
type => $types{boolean},
|
||||
category => "images",
|
||||
},
|
||||
|
@ -403,20 +403,11 @@ our @options =
|
|||
category => "network",
|
||||
},
|
||||
{
|
||||
name => "ZM_OPT_MPEG",
|
||||
name => "ZM_OPT_FFMPEG",
|
||||
default => "no",
|
||||
description => "Is there an (optional) mpeg video encoder installed",
|
||||
help => "ZoneMinder can optionally encode a series of video images into an MPEG encoded file. This option allows you to specifiy whether you have an mpeg encoder installed and if so which one. The two that ZoneMinder supports are mpeg_encode and ffmpeg, of which the latter is by far the fastest. However creating MPEG files can be fairly CPU and disk intensive and is not required as events can still be reviewed as video stream without it.",
|
||||
type => { db_type=>"string", hint=>"no|mpeg_encode|ffmpeg", pattern=>qr|^([nmf])|i, format=>q( $1 =~ /^n/ ? "no" : ( $1 =~ /^m/ ? "mpeg_encode" : "ffmpeg") ) },
|
||||
category => "images",
|
||||
},
|
||||
{
|
||||
name => "ZM_PATH_MPEG_ENCODE",
|
||||
default => "/usr/local/bin/mpeg_encode",
|
||||
description => "Path to (optional) Berkeley mpeg encoder",
|
||||
help => "This path should point to where the Berkeley mpeg_encode program has been installed.",
|
||||
requires => [ { name=>"ZM_OPT_MPEG", value=>"mpeg_encode" } ],
|
||||
type => $types{abs_path},
|
||||
description => "Is the ffmpeg video encoder/decoder installed",
|
||||
help => "ZoneMinder can optionally encode a series of video images into an MPEG encoded movie file for viewing, downloading or storage. This option allows you to specify whether you have the ffmpeg tools installed. Note that creating MPEG files can be fairly CPU and disk intensive and is not a required option as events can still be reviewed as video streams without it.",
|
||||
type => $types{boolean},
|
||||
category => "images",
|
||||
},
|
||||
{
|
||||
|
@ -424,7 +415,7 @@ our @options =
|
|||
default => "/usr/local/bin/ffmpeg",
|
||||
description => "Path to (optional) ffmpeg mpeg encoder",
|
||||
help => "This path should point to where the ffmpeg has been installed.",
|
||||
requires => [ { name=>"ZM_OPT_MPEG", value=>"ffmpeg" } ],
|
||||
requires => [ { name=>"ZM_OPT_FFMPEG", value=>"yes" } ],
|
||||
type => $types{abs_path},
|
||||
category => "images",
|
||||
},
|
||||
|
@ -433,7 +424,7 @@ our @options =
|
|||
default => "",
|
||||
description => "Additional input options to ffmpeg",
|
||||
help => "Ffmpeg can take many options on the command line to control the quality of video produced. This option allows you to specify your own set that apply to the input to ffmpeg (options that are given before the -i option). Check the ffmpeg documentation for a full list of options which may be used here.",
|
||||
requires => [ { name=>"ZM_OPT_MPEG", value=>"ffmpeg" } ],
|
||||
requires => [ { name=>"ZM_OPT_FFMPEG", value=>"yes" } ],
|
||||
type => $types{string},
|
||||
category => "images",
|
||||
},
|
||||
|
@ -442,7 +433,7 @@ our @options =
|
|||
default => "-r 25",
|
||||
description => "Additional output options to ffmpeg",
|
||||
help => "Ffmpeg can take many options on the command line to control the quality of video produced. This option allows you to specify your own set that apply to the output from ffmpeg (options that are given after the -i option). Check the ffmpeg documentation for a full list of options which may be used here. The most common one will often be to force an output frame rate supported by the video encoder.",
|
||||
requires => [ { name=>"ZM_OPT_MPEG", value=>"ffmpeg" } ],
|
||||
requires => [ { name=>"ZM_OPT_FFMPEG", value=>"yes" } ],
|
||||
type => $types{string},
|
||||
category => "images",
|
||||
},
|
||||
|
@ -451,7 +442,7 @@ our @options =
|
|||
default => "mpg* mpeg wmv avi mov 3gp**",
|
||||
description => "Formats to allow for ffmpeg video generation",
|
||||
help => "Ffmpeg can generate video in many different formats. This option allows you to list the ones you want to be able to select. As new formats are supported by ffmpeg you can add them here and be able to use them immediately. Adding a '*' after a format indicates that this will be the default format used for web video, adding '**' defines the default format for phone video.",
|
||||
requires => [ { name=>"ZM_OPT_MPEG", value=>"ffmpeg" } ],
|
||||
requires => [ { name=>"ZM_OPT_FFMPEG", value=>"yes" } ],
|
||||
type => $types{string},
|
||||
category => "images",
|
||||
},
|
||||
|
@ -1663,10 +1654,6 @@ sub loadConfigFromDB
|
|||
#next if ( $option->{category} eq 'hidden' );
|
||||
if ( defined($value) )
|
||||
{
|
||||
if ( $name eq "ZM_OPT_MPEG" && $value eq "yes" )
|
||||
{
|
||||
$value = "mpeg_encode";
|
||||
}
|
||||
if ( $option->{type} == $types{boolean} )
|
||||
{
|
||||
$option->{value} = $value?"yes":"no";
|
||||
|
|
|
@ -569,7 +569,7 @@ sub checkFilter
|
|||
my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
my $res = $sth->execute( $event->{Id} ) or Fatal( "Can't execute '$sql': ".$sth->errstr() );
|
||||
}
|
||||
if ( ZM_OPT_MPEG ne "no" && $filter->{AutoVideo} )
|
||||
if ( ZM_OPT_FFMPEG && $filter->{AutoVideo} )
|
||||
{
|
||||
if ( !$event->{Videoed} )
|
||||
{
|
||||
|
@ -871,7 +871,7 @@ sub substituteTags
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( $attachments_ref && ZM_OPT_MPEG ne "no" )
|
||||
if ( $attachments_ref && ZM_OPT_FFMPEG )
|
||||
{
|
||||
if ( $text =~ s/%EV%//g )
|
||||
{
|
||||
|
|
|
@ -100,24 +100,12 @@ if ( !$event_id || $event_id < 0 )
|
|||
Usage();
|
||||
}
|
||||
|
||||
if ( ZM_OPT_MPEG eq "no" )
|
||||
if ( ZM_OPT_FFMPEG )
|
||||
{
|
||||
print( STDERR "Mpeg encoding is not currently enabled\n" );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ( ZM_OPT_MPEG eq "mpeg_encode" && $rate != 1.0 )
|
||||
{
|
||||
print( STDERR "Variable rate not supported with mpeg_encode\n" );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ( $format ne 'mpg' && ZM_OPT_MPEG eq "mpeg_encode" )
|
||||
{
|
||||
print( STDERR "Format not supported for mpeg_encode\n" );
|
||||
Usage();
|
||||
}
|
||||
|
||||
if ( !$rate && !$fps )
|
||||
{
|
||||
$rate = 1;
|
||||
|
@ -210,132 +198,47 @@ if ( $overwrite || !-s $video_file )
|
|||
{
|
||||
Info( "Creating video file $video_file for event $event->{Id}\n" );
|
||||
|
||||
if ( ZM_OPT_MPEG eq "mpeg_encode" )
|
||||
{
|
||||
my $param_file = "$video_name.mpe";
|
||||
open( PARAMS, ">$param_file" ) or Fatal( "Can't open '$param_file': $!" );
|
||||
my $frame_rate = sprintf( "%.2f", $event->{Frames}/$event->{FullLength} );
|
||||
if ( $rate )
|
||||
{
|
||||
if ( $rate != 1.0 )
|
||||
{
|
||||
$frame_rate *= $rate;
|
||||
}
|
||||
}
|
||||
elsif ( $fps )
|
||||
{
|
||||
$frame_rate = $fps;
|
||||
}
|
||||
|
||||
print( PARAMS "PATTERN IBBPBBPBBPBBPBB\n" );
|
||||
print( PARAMS "FORCE_ENCODE_LAST_FRAME\n" );
|
||||
print( PARAMS "OUTPUT $video_file\n" );
|
||||
my $width = $event->{MonitorWidth};
|
||||
my $height = $event->{MonitorHeight};
|
||||
my $video_size = " ${width}x${height}";
|
||||
|
||||
print( PARAMS "BASE_FILE_FORMAT JPEG\n" );
|
||||
print( PARAMS "GOP_SIZE 30\n" );
|
||||
print( PARAMS "SLICES_PER_FRAME 1\n" );
|
||||
if ( $scale )
|
||||
{
|
||||
if ( $scale != 1.0 )
|
||||
{
|
||||
$width = int($width*$scale);
|
||||
$height = int($height*$scale);
|
||||
$video_size = " ${width}x${height}";
|
||||
}
|
||||
}
|
||||
elsif ( $size )
|
||||
{
|
||||
$video_size = $size;
|
||||
}
|
||||
|
||||
print( PARAMS "PIXEL HALF\n" );
|
||||
print( PARAMS "RANGE 10\n" );
|
||||
print( PARAMS "PSEARCH_ALG LOGARITHMIC\n" );
|
||||
print( PARAMS "BSEARCH_ALG CROSS2\n" );
|
||||
print( PARAMS "IQSCALE 8\n" );
|
||||
print( PARAMS "PQSCALE 10\n" );
|
||||
print( PARAMS "BQSCALE 25\n" );
|
||||
my $command = ZM_PATH_FFMPEG." -y -r $frame_rate ".ZM_FFMPEG_INPUT_OPTIONS." -i %0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg -s $video_size ".ZM_FFMPEG_OUTPUT_OPTIONS." '$video_file' >& ffmpeg.log";
|
||||
Debug( $command."\n" );
|
||||
my $output = qx($command);
|
||||
|
||||
print( PARAMS "REFERENCE_FRAME ORIGINAL\n" );
|
||||
print( PARAMS "FRAME_RATE 24\n" );
|
||||
|
||||
my $scale_conversion = "";
|
||||
if ( $scale != 1 )
|
||||
{
|
||||
if ( $scale > 1 )
|
||||
{
|
||||
$scale_conversion = ZM_PATH_NETPBM."/pnmscale $scale";
|
||||
}
|
||||
else
|
||||
{
|
||||
$scale_conversion = ZM_PATH_NETPBM."/pnmscale ".(1/$scale);
|
||||
}
|
||||
if ( $event->{Palette} == 1 && !ZM_COLOUR_JPEG_FILES )
|
||||
{
|
||||
print( PARAMS "INPUT_CONVERT ".ZM_PATH_NETPBM."/jpegtopnm * | ".$scale_conversion." | ".ZM_PATH_NETPBM."/pgmtoppm white | ".ZM_PATH_NETPBM."/ppmtojpeg\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
print( PARAMS "INPUT_CONVERT ".ZM_PATH_NETPBM."/jpegtopnm * | ".$scale_conversion." | ".ZM_PATH_NETPBM."/ppmtojpeg\n" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $event->{Palette} == 1 && !ZM_COLOUR_JPEG_FILES )
|
||||
{
|
||||
print( PARAMS "INPUT_CONVERT ".ZM_PATH_NETPBM."/jpegtopnm * | ".ZM_PATH_NETPBM."/pgmtoppm white | ".ZM_PATH_NETPBM."/ppmtojpeg\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
print( PARAMS "INPUT_CONVERT *\n" );
|
||||
}
|
||||
}
|
||||
print( PARAMS "INPUT_DIR .\n" );
|
||||
|
||||
print( PARAMS "INPUT\n" );
|
||||
for ( my $i = 1; $i <= $event->{Frames}; $i++ )
|
||||
{
|
||||
printf( PARAMS "%0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg\n", $i );
|
||||
}
|
||||
print( PARAMS "END_INPUT\n" );
|
||||
close( PARAMS );
|
||||
|
||||
my $command = ZM_PATH_MPEG_ENCODE." $param_file >mpeg_encode.log";
|
||||
Debug( $command."\n" );
|
||||
if ( my $output = qx($command) )
|
||||
{
|
||||
Debug( $output."\n" );
|
||||
}
|
||||
my $status = $? >> 8;
|
||||
if ( $status )
|
||||
{
|
||||
Fatal( "Error: $status" );
|
||||
}
|
||||
}
|
||||
elsif ( ZM_OPT_MPEG eq "ffmpeg" )
|
||||
{
|
||||
my $frame_rate = sprintf( "%.2f", $event->{Frames}/$event->{FullLength} );
|
||||
if ( $rate )
|
||||
{
|
||||
if ( $rate != 1.0 )
|
||||
{
|
||||
$frame_rate *= $rate;
|
||||
}
|
||||
}
|
||||
elsif ( $fps )
|
||||
{
|
||||
$frame_rate = $fps;
|
||||
}
|
||||
|
||||
my $width = $event->{MonitorWidth};
|
||||
my $height = $event->{MonitorHeight};
|
||||
my $video_size = " ${width}x${height}";
|
||||
|
||||
if ( $scale )
|
||||
{
|
||||
if ( $scale != 1.0 )
|
||||
{
|
||||
$width = int($width*$scale);
|
||||
$height = int($height*$scale);
|
||||
$video_size = " ${width}x${height}";
|
||||
}
|
||||
}
|
||||
elsif ( $size )
|
||||
{
|
||||
$video_size = $size;
|
||||
}
|
||||
|
||||
|
||||
my $command = ZM_PATH_FFMPEG." -y -r $frame_rate ".ZM_FFMPEG_INPUT_OPTIONS." -i %0".ZM_EVENT_IMAGE_DIGITS."d-capture.jpg -s $video_size ".ZM_FFMPEG_OUTPUT_OPTIONS." '$video_file' >& ffmpeg.log";
|
||||
Debug( $command."\n" );
|
||||
my $output = qx($command);
|
||||
|
||||
my $status = $? >> 8;
|
||||
if ( $status )
|
||||
{
|
||||
Error( "Unable to generate video, check ".$event_path."/ffmpeg.log for details" );
|
||||
exit( -1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Fatal( "Bogus mpeg option ".ZM_OPT_MPEG."\n" );
|
||||
}
|
||||
my $status = $? >> 8;
|
||||
if ( $status )
|
||||
{
|
||||
Error( "Unable to generate video, check ".$event_path."/ffmpeg.log for details" );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
Info( "Finished $video_file\n" );
|
||||
}
|
||||
|
|
|
@ -1067,10 +1067,6 @@ $OLANG = array(
|
|||
'Prompt' => "Este instalat codor video mpeg (opţional)",
|
||||
'Help' => "ZoneMinder poate înregistra o serie de imagini în format MPEG. Această opţiune vă permite să specificaţi dacă aveţi un codor mpeg instalat. Cele două codoare suportate de ZoneMinder sunt mpeg_encode şi ffmpeg, ultimul fiind cel mai rapid. Crearea de fişiere MPEG consumă resursele procesorului şi nu este necesară deoarece evenimentele pot fi vizualizare ca flux video."
|
||||
),
|
||||
'PATH_MPEG_ENCODE' => array(
|
||||
'Prompt' => "Calea la codorul mpeg Berkeley (opţional)",
|
||||
'Help' => "Aceasta este calea la codorul mpeg Berkeley (opţional)."
|
||||
),
|
||||
'PATH_FFMPEG' => array(
|
||||
'Prompt' => "Calea la codorul mpeg ffmpeg (opţional)",
|
||||
'Help' => "Aceasta este calea la codorul mpeg ffmpeg."
|
||||
|
|
Loading…
Reference in New Issue