0

When I try to use GPU FFMPEG on opencv by using a command like:

VideoCapture cap("rtsp link");

for(;;)
{
mat frame;
cap>>frame;
}

I don't see any output on nvidia-smi despite compiling the GPU version of FFMPEG.

I am trying to get FFMPEG to use GPU to improve the speed of my program. I got FFMPEG from cloning this and followed the steps here to get it working.

I have validated the results using nvidia-smi dmon -i 0 and have seen that dec% increases when I run the command ffmpeg -c:v h264_cuvid -i test_video.mp4 test_output.mkv.

I then compiled Opencv to use the GPU enabled FFMPEG, I check this by running getBuildInformation from opencv:

Video I/O: 
DC1394 1.x: NO 
DC1394 2.x: YES (ver 2.2.4) 
FFMPEG: YES 
codec: YES (ver 58.20.103) 
format: YES (ver 58.17.100) 
util: YES (ver 56.18.102) 
swscale: YES (ver 5.2.100) 
resample: NO 
gentoo-style: YES 
GStreamer: NO 
OpenNI: NO 
OpenNI PrimeSensor Modules: NO 
OpenNI2: NO 
PvAPI: NO 
GigEVisionSDK: NO 
UniCap: NO 
UniCap ucil: NO 
V4L/V4L2: NO/YES 
XIMEA: NO 
Xine: NO 
gPhoto2: NO

I cross-verify that I'm using the same ffmpeg (by checking the version numbers):

ffmpeg version N-91273-g67747c8 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
  configuration: --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64
  libavutil      56. 18.102 / 56. 18.102
  libavcodec     58. 20.101 / 58. 20.101
  libavformat    58. 17.100 / 58. 17.100
  libavdevice    58.  4.101 / 58.  4.101
  libavfilter     7. 25.100 /  7. 25.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100

Please advise me on how I should compile OpenCV to use the GPU version of FFMPEG. Thank you!

1 Answer 1

0

Not strictly FFmpeg related, but as an advise for you to be able to use hugely performant GPU capabilities through OpenCV API.

Assuming that you use OpenCV 3.x.x - you should use special OpenCV GPU Api for video decoding. Take a look on this example from official documentation:

Also, foreseeing the problems with compilation and running the code with modern OpenCV 3.4.1 and >=CUDA 9.0, read through my comment on OpenCV's issue tracker to overcome those:

And also yes - it will give you huge speed-up on video decoding/reading. Absolutely worth trying.

6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.