From 86e8b5856123f6a59c34a52b79715be815d5ace4 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 25 Jun 2019 22:06:00 -0400 Subject: [PATCH 1/2] move hw_device_ctx under ifdef for HWCONTEXT_H --- src/zm_ffmpeg_camera.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_ffmpeg_camera.h b/src/zm_ffmpeg_camera.h index 210a67f45..3eb52d1f8 100644 --- a/src/zm_ffmpeg_camera.h +++ b/src/zm_ffmpeg_camera.h @@ -63,8 +63,8 @@ class FfmpegCamera : public Camera { AVFrame *hwFrame; #if HAVE_LIBAVUTIL_HWCONTEXT_H DecodeContext decode; -#endif AVBufferRef *hw_device_ctx = NULL; +#endif // Used to store the incoming packet, it will get copied when queued. // We only ever need one at a time, so instead of constantly allocating From 2a65b339c141fae0175fea896af53918a2761a3d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 25 Jun 2019 22:19:09 -0400 Subject: [PATCH 2/2] init hw_pix_fmt in constructor --- src/zm_ffmpeg_camera.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index f69e13777..9a3c3a3bc 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -151,6 +151,9 @@ FfmpegCamera::FfmpegCamera( have_video_keyframe = false; packetqueue = NULL; error_count = 0; +#if HAVE_LIBAVUTIL_HWCONTEXT_H + hw_pix_fmt = AV_PIX_FMT_NONE; +#endif #if HAVE_LIBSWSCALE mConvertContext = NULL; @@ -915,7 +918,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event if ( error_count > 0 ) error_count --; zm_dump_video_frame(mRawFrame); #if HAVE_LIBAVUTIL_HWCONTEXT_H - if ( mRawFrame->format == hw_pix_fmt ) { + if ( hw_pix_fmt != mRawFrame->format == hw_pix_fmt ) { /* retrieve data from GPU to CPU */ ret = av_hwframe_transfer_data(hwFrame, mRawFrame, 0); if ( ret < 0 ) {