无法将硬件加速ffmpeg解码器转换为原始环回设备

无法将硬件加速ffmpeg解码器转换为原始环回设备,ffmpeg,rtsp,hardware-acceleration,v4l2loopback,Ffmpeg,Rtsp,Hardware Acceleration,V4l2loopback,在接触之前,我在谷歌上搜索了很多,尝试了许多不同的docker容器、构建、编译等 我要寻找的是从rtsp流到/dev/video0设备的硬件加速转换。我有一个工作的v4l2loopback内核模块,下面的命令正在工作: ffmpeg -loglevel panic -hide_banner -i "rtsp://192.168.0.17/user=admin&password=&channel=1&stream=0.dsp?real_stream" -f v4l2 -pi

在接触之前,我在谷歌上搜索了很多,尝试了许多不同的docker容器、构建、编译等

我要寻找的是从rtsp流到/dev/video0设备的硬件加速转换。我有一个工作的v4l2loopback内核模块,下面的命令正在工作:

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
我可以测试/dev/video0设备以获取屏幕截图:

ffmpeg -f video4linux2 -i /dev/video0 -ss 0:0:2 -frames 1 /var/www/html/out.png
上面的方法是可行的,但解码/编码需要大约30/50%的cpu使用率

我有一个使用GeForce GTX 1050的完全工作的测试环境。所有cuda/nvidia相关驱动程序均已到位。ffmpeg使用以下选项编译:

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
我最后一次尝试是:

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
这给了我一个错误:

无法在筛选器“Parsed_null_0”和筛选器“auto_scaler_0”支持的格式之间转换 重新初始化筛选器时出错! 无法将帧注入筛选器网络:未实现函数 处理流#0:0的解码数据时出错

我现在完全不知道如何解决这个问题

提前谢谢

//补充信息

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

我在beginpost中添加了这两个命令的输出。谢谢我在begin post中添加了这两个命令的输出。非常感谢。