Merge branch 'master' of github.com:ZoneMinder/zoneminder

This commit is contained in:
Isaac Connor 2020-08-05 20:00:45 -04:00
commit ef2ad12846
2 changed files with 35 additions and 40 deletions

View File

@ -40,16 +40,7 @@ VideoStream::MimeData VideoStream::mime_data[] = {
}; };
void VideoStream::Initialise( ) { void VideoStream::Initialise( ) {
if ( logDebugging() ) { FFMPEGInit();
av_log_set_level( AV_LOG_DEBUG );
} else {
av_log_set_level( AV_LOG_QUIET );
}
av_register_all( );
#if LIBAVFORMAT_VERSION_CHECK(53, 13, 0, 19, 0)
avformat_network_init();
#endif
initialised = true; initialised = true;
} }
@ -57,23 +48,23 @@ void VideoStream::SetupFormat( ) {
/* allocate the output media context */ /* allocate the output media context */
ofc = NULL; ofc = NULL;
#if (LIBAVFORMAT_VERSION_CHECK(53, 2, 0, 2, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100)) #if (LIBAVFORMAT_VERSION_CHECK(53, 2, 0, 2, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100))
avformat_alloc_output_context2( &ofc, NULL, format, filename ); avformat_alloc_output_context2(&ofc, NULL, format, filename);
#else #else
AVFormatContext *s= avformat_alloc_context(); AVFormatContext *s = avformat_alloc_context();
if(!s) { if ( !s ) {
Fatal( "avformat_alloc_context failed %d \"%s\"", (size_t)ofc, av_err2str((size_t)ofc) ); Fatal("avformat_alloc_context failed %d \"%s\"", (size_t)ofc, av_err2str((size_t)ofc));
return; return;
} }
AVOutputFormat *oformat; AVOutputFormat *oformat;
if (format) { if ( format ) {
#if LIBAVFORMAT_VERSION_CHECK(52, 45, 0, 45, 0) #if LIBAVFORMAT_VERSION_CHECK(52, 45, 0, 45, 0)
oformat = av_guess_format(format, NULL, NULL); oformat = av_guess_format(format, NULL, NULL);
#else #else
oformat = guess_format(format, NULL, NULL); oformat = guess_format(format, NULL, NULL);
#endif #endif
if (!oformat) { if ( !oformat ) {
Fatal( "Requested output format '%s' is not a suitable output format", format ); Fatal("Requested output format '%s' is not a suitable output format", format);
} }
} else { } else {
#if LIBAVFORMAT_VERSION_CHECK(52, 45, 0, 45, 0) #if LIBAVFORMAT_VERSION_CHECK(52, 45, 0, 45, 0)
@ -81,47 +72,47 @@ void VideoStream::SetupFormat( ) {
#else #else
oformat = guess_format(NULL, filename, NULL); oformat = guess_format(NULL, filename, NULL);
#endif #endif
if (!oformat) { if ( !oformat ) {
Fatal( "Unable to find a suitable output format for '%s'", format ); Fatal("Unable to find a suitable output format for '%s'", format);
} }
} }
s->oformat = oformat; s->oformat = oformat;
if (s->oformat->priv_data_size > 0) { if ( s->oformat->priv_data_size > 0 ) {
s->priv_data = av_mallocz(s->oformat->priv_data_size); s->priv_data = av_mallocz(s->oformat->priv_data_size);
if ( !(s->priv_data) ) { if ( !(s->priv_data) ) {
Fatal( "Could not allocate private data for output format." ); Fatal("Could not allocate private data for output format.");
} }
#if LIBAVFORMAT_VERSION_CHECK(52, 92, 0, 92, 0) #if LIBAVFORMAT_VERSION_CHECK(52, 92, 0, 92, 0)
if (s->oformat->priv_class) { if ( s->oformat->priv_class ) {
*(const AVClass**)s->priv_data = s->oformat->priv_class; *(const AVClass**)s->priv_data = s->oformat->priv_class;
av_opt_set_defaults(s->priv_data); av_opt_set_defaults(s->priv_data);
} }
#endif #endif
} else { } else {
Debug(1,"No allocating priv_data"); Debug(1, "No allocating priv_data");
s->priv_data = NULL; s->priv_data = NULL;
} }
if ( filename ) { if ( filename ) {
snprintf( s->filename, sizeof(s->filename), "%s", filename ); snprintf(s->filename, sizeof(s->filename), "%s", filename);
} }
ofc = s; ofc = s;
#endif #endif
if ( !ofc ) { if ( !ofc ) {
Fatal( "avformat_alloc_..._context failed: %d", ofc ); Fatal("avformat_alloc_..._context failed: %d", ofc);
} }
of = ofc->oformat; of = ofc->oformat;
Debug( 1, "Using output format: %s (%s)", of->name, of->long_name ); Debug(1, "Using output format: %s (%s)", of->name, of->long_name);
} }
void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int height, int bitrate, double frame_rate ) { void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int height, int bitrate, double frame_rate ) {
/* ffmpeg format matching */ /* ffmpeg format matching */
switch(colours) { switch ( colours ) {
case ZM_COLOUR_RGB24: case ZM_COLOUR_RGB24:
if(subpixelorder == ZM_SUBPIX_ORDER_BGR) { if ( subpixelorder == ZM_SUBPIX_ORDER_BGR ) {
/* BGR subpixel order */ /* BGR subpixel order */
pf = AV_PIX_FMT_BGR24; pf = AV_PIX_FMT_BGR24;
} else { } else {
@ -130,13 +121,13 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
} }
break; break;
case ZM_COLOUR_RGB32: case ZM_COLOUR_RGB32:
if(subpixelorder == ZM_SUBPIX_ORDER_ARGB) { if ( subpixelorder == ZM_SUBPIX_ORDER_ARGB ) {
/* ARGB subpixel order */ /* ARGB subpixel order */
pf = AV_PIX_FMT_ARGB; pf = AV_PIX_FMT_ARGB;
} else if(subpixelorder == ZM_SUBPIX_ORDER_ABGR) { } else if ( subpixelorder == ZM_SUBPIX_ORDER_ABGR ) {
/* ABGR subpixel order */ /* ABGR subpixel order */
pf = AV_PIX_FMT_ABGR; pf = AV_PIX_FMT_ABGR;
} else if(subpixelorder == ZM_SUBPIX_ORDER_BGRA) { } else if ( subpixelorder == ZM_SUBPIX_ORDER_BGRA ) {
/* BGRA subpixel order */ /* BGRA subpixel order */
pf = AV_PIX_FMT_BGRA; pf = AV_PIX_FMT_BGRA;
} else { } else {
@ -152,7 +143,7 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
break; break;
} }
if ( strcmp( "rtp", of->name ) == 0 ) { if ( strcmp("rtp", of->name) == 0 ) {
// RTP must have a packet_size. // RTP must have a packet_size.
// Not sure what this value should be really... // Not sure what this value should be really...
ofc->packet_size = width*height; ofc->packet_size = width*height;
@ -169,12 +160,12 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
AVCodec *a = avcodec_find_encoder_by_name(codec_name); AVCodec *a = avcodec_find_encoder_by_name(codec_name);
if ( a ) { if ( a ) {
codec_id = a->id; codec_id = a->id;
Debug( 1, "Using codec \"%s\"", codec_name ); Debug(1, "Using codec \"%s\"", codec_name);
} else { } else {
#if (LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 11, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100)) #if (LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 11, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100))
Debug( 1, "Could not find codec \"%s\". Using default \"%s\"", codec_name, avcodec_get_name( codec_id ) ); Debug(1, "Could not find codec \"%s\". Using default \"%s\"", codec_name, avcodec_get_name(codec_id));
#else #else
Debug( 1, "Could not find codec \"%s\". Using default \"%d\"", codec_name, codec_id ); Debug(1, "Could not find codec \"%s\". Using default \"%d\"", codec_name, codec_id);
#endif #endif
} }
} }
@ -183,19 +174,19 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
and initialize the codecs */ and initialize the codecs */
ost = NULL; ost = NULL;
if ( codec_id != AV_CODEC_ID_NONE ) { if ( codec_id != AV_CODEC_ID_NONE ) {
codec = avcodec_find_encoder( codec_id ); codec = avcodec_find_encoder(codec_id);
if ( !codec ) { if ( !codec ) {
#if (LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 11, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100)) #if (LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 11, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100))
Fatal( "Could not find encoder for '%s'", avcodec_get_name( codec_id ) ); Fatal("Could not find encoder for '%s'", avcodec_get_name(codec_id));
#else #else
Fatal( "Could not find encoder for '%d'", codec_id ); Fatal("Could not find encoder for '%d'", codec_id);
#endif #endif
} }
#if (LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 11, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100)) #if (LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 11, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100))
Debug( 1, "Found encoder for '%s'", avcodec_get_name( codec_id ) ); Debug(1, "Found encoder for '%s'", avcodec_get_name(codec_id));
#else #else
Debug( 1, "Found encoder for '%d'", codec_id ); Debug(1, "Found encoder for '%d'", codec_id);
#endif #endif
#if LIBAVFORMAT_VERSION_CHECK(53, 10, 0, 17, 0) #if LIBAVFORMAT_VERSION_CHECK(53, 10, 0, 17, 0)

View File

@ -1,3 +1,7 @@
<?php
global $filterQuery;
global $monitors;
?>
var filterQuery = '<?php echo validJsStr($filterQuery) ?>'; var filterQuery = '<?php echo validJsStr($filterQuery) ?>';
<?php <?php