Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
Description
System Information
ubuntu 24.04
ffmpeg 6.1, with h264_cuvid working
gpu nvidia rtx-5060
opencv 4.12.0
cmake:
cmake -D CMAKE_BUILD_TYPE=Release
-D CMAKE_INSTALL_PREFIX=/mnt/soft/apps/third-party/opencv-4.12/opencv/install
-D OPENCV_EXTRA_MODULES_PATH=/mnt/soft/apps/third-party/opencv-4.12/opencv_contrib/modules
-D WITH_FFMPEG=ON
-D FFMPEG_INCLUDE_DIR=/mnt/soft/apps/third-party/ffmpeg-6.1/include
-D FFMPEG_LIB_DIR=/mnt/soft/apps/third-party/ffmpeg-6.1/lib
-D OPENCV_FFMPEG_SKIP_BUILD_CHECK=ON
-D BUILD_opencv_java=ON
-D BUILD_SHARED_LIBS=ON
-D WITH_OPENCL=OFF
-D BUILD_TESTS=OFF
-D BUILD_PERF_TESTS=OFF
-D WITH_CUDA=ON
-D CUDA_ARCH_BIN=120
-D WITH_CUDNN=OFF
-D USE_AV_HW_CODECS=ON
..
run: ffmpeg -c:v h264_cuvid -i /mnt/data/test_video/20251022.mp4 -f null -
aicf@aicf:~$ nvidia-smi dmon -s pucvmet -i 0
gpu pwr gtemp mtemp sm mem enc dec jpg ofa mclk pclk pviol tviol fb bar1 ccpm sbecc dbecc pci rxpci txpci
Idx W C C % % % % % % MHz MHz % bool MB MB MB errs errs errs MB/s MB/s
0 11 37 - 0 0 0 0 0 0 405 180 100 0 2 2 0 - - 0 0 00 21 39 - 39 0 0 90 0 0 13801 2790 35 0 136 5 0 - - 0 101 56290 32 39 - 0 0 0 0 0 0 14001 2790 0 0 2 2 0 - - 0 0 00 29 39 - 0 0 0 0 0 0 14001 2790 0 0 2 2 0 - - 0 0 0Detailed description
root@aicf:/mnt/soft/apps/opencv4.demo# export OPENCV_FFMPEG_CAPTURE_OPTIONS="video_codec=h264_cuvid"
root@aicf:/mnt/soft/apps/opencv4.demo# export OPENCV_LOG_LEVEL=DEBUG
root@aicf:/mnt/soft/apps/opencv4.demo# export OPENCV_VIDEOIO_DEBUG=1
root@aicf:/mnt/soft/apps/opencv4.demo# java -Djava.library.path=. -cp .:opencv-4120.jar VideoDecodeTest 2>&1 | grep FFMPEG
[DEBUG:0@0.005] global videoio_registry.cpp:225 VideoBackendRegistry VIDEOIO: Builtin backends(9): FFMPEG(1000); FFMPEG(990); GSTREAMER(980); INTEL_MFX(970); V4L2(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930); OBSENSOR(920)
[DEBUG:0@0.005] global videoio_registry.cpp:249 VideoBackendRegistry VIDEOIO: Available backends(9): FFMPEG(1000); FFMPEG(990); GSTREAMER(980); INTEL_MFX(970); V4L2(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930); OBSENSOR(920)
[ INFO:0@0.005] global videoio_registry.cpp:251 VideoBackendRegistry VIDEOIO: Enabled backends(9, sorted by priority): FFMPEG(1000); FFMPEG(990); GSTREAMER(980); INTEL_MFX(970); V4L2(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930); OBSENSOR(920)
[ WARN:0@0.005] global cap.cpp:141 open VIDEOIO(FFMPEG): trying capture filename='/mnt/data/test_video/20251022.mp4' ...
[DEBUG:0@0.005] global cap_ffmpeg_impl.hpp:1150 open VIDEOIO/FFMPEG: using capture options from environment: video_codec=h264_cuvid;hw_decoders_ANY=cuda
[DEBUG:0@0.009] global cap_ffmpeg_impl.hpp:1268 open FFMPEG: stream[0] is video stream with codecID=27 width=704 height=576
[DEBUG:0@0.009] global cap_ffmpeg_hw.hpp:934 HWAccelIterator FFMPEG: allowed acceleration types (any): 'vaapi.iHD,'
[DEBUG:0@0.009] global cap_ffmpeg_hw.hpp:952 HWAccelIterator FFMPEG: disabled codecs: 'av1.vaapi,av1_qsv,vp8.vaapi,vp8_qsv'
[DEBUG:0@0.009] global cap_ffmpeg_impl.hpp:1293 open FFMPEG: trying to configure H/W acceleration: 'vaapi.iHD'
[ INFO:0@0.009] global cap_ffmpeg_hw.hpp:601 hw_create_device FFMPEG: Failed to create vaapi video acceleration (av_hwdevice_ctx_create) on device 'default'
[DEBUG:0@0.009] global cap_ffmpeg_impl.hpp:1312 open FFMPEG: ... can't create H/W device: 'vaapi.iHD'
[ WARN:0@0.013] global cap.cpp:153 open VIDEOIO(FFMPEG): created, isOpened=1
h264_cuvid or CUDA related decoders are not in decoder list, and nvidia hw decoder is not working.
aicf@aicf:~$ nvidia-smi dmon -s pucvmet -i 0
gpu pwr gtemp mtemp sm mem enc dec jpg ofa mclk pclk pviol tviol fb bar1 ccpm sbecc dbecc pci rxpci txpci
Idx W C C % % % % % % MHz MHz % bool MB MB MB errs errs errs MB/s MB/s
0 11 36 - 0 0 0 0 0 0 405 180 0 0 2 2 0 - - 0 0 00 11 36 - 0 0 0 0 0 0 405 180 100 0 2 2 0 - - 0 0 00 11 36 - 0 0 0 0 0 0 405 180 100 0 2 2 0 - - 0 0 00 11 36 - 0 0 0 0 0 0 405 180 100 0 2 2 0 - - 0 0 00 11 36 - 0 0 0 0 0 0 405 180 100 0 2 2 0 - - 0 0 00 11 36 - 0 0 0 0 0 0 405 180 100 0 2 2 0 - - 0 0 00 11 36 - 0 0 0 0 0 0 405 180 100 0 2 2 0 - - 0 0 00 11 36 - 0 0 0 0 0 0 405 180 100 0 2 2 0 - - 0 0 00 11 36 - 0 0 0 0 0 0 405 180 100 0 2 2 0 - - 0 0 00 11 36 - 0 0 0 0 0 0 405 180 100 0 2 2 0 - - 0 0 1Steps to reproduce
test using java code like this:
root@aicf:/mnt/soft/apps/opencv4.demo# cat VideoDecodeTest.java
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfInt;
import org.opencv.videoio.VideoCapture;
import org.opencv.videoio.Videoio;
public class VideoDecodeTest {
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
MatOfInt params = new MatOfInt(); params.fromArray( Videoio.CAP_PROP_HW_ACCELERATION, Videoio.VIDEO_ACCELERATION_ANY// Videoio.CAP_PROP_HW_DEVICE, 0
);
VideoCapture capture = new VideoCapture( "/mnt/data/test_video/20251022.mp4", Videoio.CAP_FFMPEG, params ); if (!capture.isOpened()) { System.err.println("open error"); return; } double hwAccel = capture.get(Videoio.CAP_PROP_HW_ACCELERATION); System.out.println("hw access... =: " + hwAccel); Mat frame = new Mat(); while (capture.read(frame)) { System.out.println("frame, y:" + frame.width() + ", x:" + frame.height()); } capture.release(); }}
cmds:
root@aicf:/mnt/soft/apps/opencv4.demo# export OPENCV_FFMPEG_CAPTURE_OPTIONS="video_codec=h264_cuvid"
root@aicf:/mnt/soft/apps/opencv4.demo# export OPENCV_LOG_LEVEL=DEBUG
root@aicf:/mnt/soft/apps/opencv4.demo# export OPENCV_VIDEOIO_DEBUG=1
root@aicf:/mnt/soft/apps/opencv4.demo# java -Djava.library.path=. -cp .:opencv-4120.jar VideoDecodeTest 2>&1 | grep FFMPEG
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)