diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 3386d8ef..7910693c 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -221,9 +221,15 @@ void FFmpegReader::Open() #if defined(__linux__) if (hw_de_on & hw_de_supported) { // Open Hardware Acceleration + // Use the hw device given in the environment variable HW_DE_DEVICE_SET or the default if not set + char *dev_hw = getenv( "HW_DE_DEVICE_SET" ); + // Check if it is there and writable + if( dev_hw != NULL && access( dev_hw, W_OK ) == -1 ) { + dev_hw = NULL; // use default + } hw_device_ctx = NULL; pCodecCtx->get_format = get_vaapi_format; - if (av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, NULL, NULL, 0) >= 0) { + if (av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, dev_hw, NULL, 0) >= 0) { if (!(pCodecCtx->hw_device_ctx = av_buffer_ref(hw_device_ctx))) { throw InvalidCodec("Hardware device reference create failed.", path); } diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 5c902021..24ccec0a 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -1178,8 +1178,8 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) #if IS_FFMPEG_3_2 #if defined(__linux__) if (hw_en_on && hw_en_supported) { - // Use the hw device given in the environment variable HW_DEVICE_SET or the default if not set - char *dev_hw = getenv( "HW_DEVICE_SET" ); + // Use the hw device given in the environment variable HW_EN_DEVICE_SET or the default if not set + char *dev_hw = getenv( "HW_EN_DEVICE_SET" ); // Check if it is there and writable if( dev_hw != NULL && access( dev_hw, W_OK ) == -1 ) { dev_hw = NULL; // use default