Before reaching out, i googled enough, tried many different docker containers, building, compiling etc etc.
What I am looking for is a hardware accelerated conversion from a rtsp stream to a /dev/video0 device. I have a working v4l2loopback kernel module, and the following command is working:
ffmpeg -loglevel panic -hide_banner -i "rtsp://192.168.0.17/user=admin&password=&channel=1&stream=0.dsp?real_stream" -f v4l2 -pix_fmt yuv420p /dev/video0
I can test the /dev/video0 device to take a screenshot:
ffmpeg -f video4linux2 -i /dev/video0 -ss 0:0:2 -frames 1 /var/www/html/out.png
Above is working, but taking around 30 / 50% cpu usage to decode/encoding.
I have a fully working test environment with a GeForce GTX 1050. All cuda / nvidia related drivers are in place. ffmpeg is compiled with the following options:
configuration: --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/cuda/lib64
My last attempt was:
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i "rtsp://192.168.0.17/user=admin&password=&channel=1&stream=0.dsp?real_stream" -c:v rawvideo -pix_fmt yuv420p -f v4l2 /dev/video0
It gives me an error:
Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0' Error reinitializing filters! Failed to inject frame into filter network: Function not implemented Error while processing the decoded data for stream #0:0
I have at the moment absolute no idea anymore how to solve this.
Thanks in advance!
//added information
root@localhost:~# ffmpeg -i "rtsp://192.168.0.17/user=admin&password=&channel=1&stream=0.dsp?real_stream" -c copy -f v4l2 /dev/video0
ffmpeg version N-91067-g1c2e5fc Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
configuration: --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/cuda/lib64
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 19.101 / 58. 19.101
libavformat 58. 13.102 / 58. 13.102
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 22.100 / 7. 22.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
Input #0, rtsp, from 'rtsp://192.168.0.17/user=admin&password=&channel=1&stream=0.dsp?real_stream':
Metadata:
title : RTSP Session
Duration: N/A, start: 2.300000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 10 fps, 10 tbr, 90k tbn, 20 tbc
[v4l2 @ 0x31a7f00] V4L2 output device supports only a single raw video stream
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Last message repeated 1 times
root@localhost:~#
root@localhost:~# ffmpeg -i "rtsp://192.168.0.17/user=admin&password=&channel=1&stream=0.dsp?real_stream" -f v4l2 -pix_fmt yuv420p /dev/video0 ffmpeg version N-91067-g1c2e5fc Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
configuration: --enable-nonfree --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/cuda/lib64
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 19.101 / 58. 19.101
libavformat 58. 13.102 / 58. 13.102
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 22.100 / 7. 22.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
Input #0, rtsp, from 'rtsp://192.168.0.17/user=admin&password=&channel=1&stream=0.dsp?real_stream':
Metadata:
title : RTSP Session
Duration: N/A, start: 2.300000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 10 fps, 10 tbr, 90k tbn, 20 tbc
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[swscaler @ 0x2821240] deprecated pixel format used, make sure you did set range correctly
Output #0, v4l2, to '/dev/video0':
Metadata:
title : RTSP Session
encoder : Lavf58.13.102
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, q=2-31, 248832 kb/s, 10 fps, 10 tbn, 10 tbc
Metadata:
encoder : Lavc58.19.101 rawvideo
frame= 85 fps= 13 q=-0.0 Lsize=N/A time=00:00:08.50 bitrate=N/A dup=0 drop=4 speed=1.31x
video:258188kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown