Handle failure to init hwdevice when trying to use hwaccel.

This commit is contained in:
Isaac Connor 2020-01-05 17:27:45 -05:00
parent cc6d40d67e
commit 05ac82b0bb
1 changed files with 7 additions and 7 deletions

View File

@ -517,17 +517,17 @@ int FfmpegCamera::OpenFfmpeg() {
Debug(1, "Selected hw_pix_fmt %d %s", Debug(1, "Selected hw_pix_fmt %d %s",
hw_pix_fmt, av_get_pix_fmt_name(hw_pix_fmt)); hw_pix_fmt, av_get_pix_fmt_name(hw_pix_fmt));
mVideoCodecContext->get_format = get_hw_format;
ret = av_hwdevice_ctx_create(&hw_device_ctx, type, ret = av_hwdevice_ctx_create(&hw_device_ctx, type,
(hwaccel_device != "" ? hwaccel_device.c_str(): NULL), NULL, 0); (hwaccel_device != "" ? hwaccel_device.c_str(): NULL), NULL, 0);
if ( ret < 0 ) { if ( ret < 0 ) {
Error("Failed to create hwaccel device."); Error("Failed to create hwaccel device.");
return -1; hw_pix_fmt = AV_PIX_FMT_NONE;
} else {
Debug(1, "Created hwdevice for %s", hwaccel_device.c_str());
mVideoCodecContext->get_format = get_hw_format;
mVideoCodecContext->hw_device_ctx = av_buffer_ref(hw_device_ctx);
hwFrame = zm_av_frame_alloc();
} }
Debug(1, "Created hwdevice for %s", hwaccel_device.c_str());
mVideoCodecContext->hw_device_ctx = av_buffer_ref(hw_device_ctx);
hwFrame = zm_av_frame_alloc();
} else { } else {
Debug(1, "Failed to setup hwaccel."); Debug(1, "Failed to setup hwaccel.");
} }
@ -537,7 +537,7 @@ int FfmpegCamera::OpenFfmpeg() {
#else #else
Warning("HWAccel support not compiled in."); Warning("HWAccel support not compiled in.");
#endif #endif
} // end if hwacel_name } // end if hwaccel_name
// Open the codec // Open the codec
#if !LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 8, 0) #if !LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 8, 0)