refactor: update FFmpeg hardware acceleration to use NVDEC instead of CUVID for improved performance
All checks were successful
Build Worker Base and Application Images / check-base-changes (push) Successful in 8s
Build Worker Base and Application Images / build-base (push) Has been skipped
Build Worker Base and Application Images / build-docker (push) Successful in 3m2s
Build Worker Base and Application Images / deploy-stack (push) Successful in 10s
All checks were successful
Build Worker Base and Application Images / check-base-changes (push) Successful in 8s
Build Worker Base and Application Images / build-base (push) Has been skipped
Build Worker Base and Application Images / build-docker (push) Successful in 3m2s
Build Worker Base and Application Images / deploy-stack (push) Successful in 10s
This commit is contained in:
parent
bdbf688946
commit
cb9ff7bc86
2 changed files with 7 additions and 9 deletions
|
@ -208,20 +208,20 @@ class RTSPReader:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"Camera {self.camera_id}: FFmpeg optimal hardware acceleration not available: {e}")
|
logger.debug(f"Camera {self.camera_id}: FFmpeg optimal hardware acceleration not available: {e}")
|
||||||
|
|
||||||
# Method 3: Try FFmpeg with basic NVIDIA CUVID
|
# Method 3: Try FFmpeg with NVIDIA NVDEC (better for RTX 3060)
|
||||||
if not hw_accel_success:
|
if not hw_accel_success:
|
||||||
try:
|
try:
|
||||||
import os
|
import os
|
||||||
os.environ['OPENCV_FFMPEG_CAPTURE_OPTIONS'] = 'video_codec;h264_cuvid|rtsp_transport;tcp|hwaccel;cuda|hwaccel_device;0'
|
os.environ['OPENCV_FFMPEG_CAPTURE_OPTIONS'] = 'hwaccel;cuda|hwaccel_device;0|rtsp_transport;tcp'
|
||||||
|
|
||||||
logger.info(f"Attempting FFmpeg with basic CUVID for camera {self.camera_id}")
|
logger.info(f"Attempting FFmpeg with NVDEC hardware acceleration for camera {self.camera_id}")
|
||||||
self.cap = cv2.VideoCapture(self.rtsp_url, cv2.CAP_FFMPEG)
|
self.cap = cv2.VideoCapture(self.rtsp_url, cv2.CAP_FFMPEG)
|
||||||
|
|
||||||
if self.cap.isOpened():
|
if self.cap.isOpened():
|
||||||
hw_accel_success = True
|
hw_accel_success = True
|
||||||
logger.info(f"Camera {self.camera_id}: Using FFmpeg CUVID hardware acceleration")
|
logger.info(f"Camera {self.camera_id}: Using FFmpeg NVDEC hardware acceleration")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"Camera {self.camera_id}: FFmpeg CUVID not available: {e}")
|
logger.debug(f"Camera {self.camera_id}: FFmpeg NVDEC not available: {e}")
|
||||||
|
|
||||||
# Method 4: Try FFmpeg with VAAPI (Intel/AMD GPUs)
|
# Method 4: Try FFmpeg with VAAPI (Intel/AMD GPUs)
|
||||||
if not hw_accel_success:
|
if not hw_accel_success:
|
||||||
|
|
|
@ -109,11 +109,9 @@ class FFmpegCapabilities:
|
||||||
if codec == 'h264':
|
if codec == 'h264':
|
||||||
options.update({
|
options.update({
|
||||||
'hwaccel': 'cuda',
|
'hwaccel': 'cuda',
|
||||||
'hwaccel_device': '0',
|
'hwaccel_device': '0'
|
||||||
'video_codec': 'h264_cuvid',
|
|
||||||
'hwaccel_output_format': 'cuda'
|
|
||||||
})
|
})
|
||||||
logger.info("Using NVIDIA CUVID hardware acceleration for H.264")
|
logger.info("Using NVIDIA NVDEC hardware acceleration for H.264")
|
||||||
elif codec == 'h265':
|
elif codec == 'h265':
|
||||||
options.update({
|
options.update({
|
||||||
'hwaccel': 'cuda',
|
'hwaccel': 'cuda',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue