如何使用硬件解码器将视频数据直接渲染到屏幕上?
我正在使用 orangepipc (H3)。
如果我使用 mpv 播放器,它可以正常工作。
sudo mpv av://v4l2:/dev/video0 --vo=vdpau --hwdec=vdpau --hwdec-codecs=all --fs
但我只想使用 ffmpeg 来完成同样的工作:
$ sudo ./ffmpeg -hwaccel vdpau -f v4l2 -channel 0 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 10
ffmpeg version 3.3.git Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --prefix=/usr --enable-nonfree --enable-gpl --enable-version3 --enable-vdpau --enable-libx264 --enable-libmp3lame --enable-libpulse --enable-libv4l2
libavutil 55. 63.100 / 55. 63.100
libavcodec 57. 96.101 / 57. 96.101
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 90.100 / 6. 90.100
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
Trailing options were found on the commandline.
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 1503479273.620903, bitrate: 88473 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, 88473 kb/s, 8 fps, 8 tbr, 1000k tbn, 1000k tbc
At least one output file must be specified
编辑:
$ sudo ./ffmpeg -devices
...
Devices:
D. = Demuxing supported
.E = Muxing supported
--
DE alsa ALSA audio output
D dv1394 DV1394 A/V grab
DE fbdev Linux framebuffer
D jack JACK Audio Connection Kit
D lavfi Libavfilter virtual input device
DE oss OSS (Open Sound System) playback
DE pulse Pulse audio output
E v4l2 Video4Linux2 output device
D video4linux2,v4l2 Video4Linux2 device grab
D x11grab X11 screen capture, using XCB
E xv XV (XVideo) output device
仍然收到一些错误信息:
$ DISPLAY=:0 sudo ./ffmpeg -hwaccel vdpau -f v4l2 -channel 0 -video_size 1280x720 -i /dev/video0 -f xv display
...
Input #0, video4linux2,v4l2, from '/dev/video0':
Duration: N/A, start: 1503483702.709213, bitrate: 88473 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, 88473 kb/s, 8 fps, 8 tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[xv @ 0x2551040] No X-Video adaptors present
Could not write header for output file #0 (incorrect codec parameters ?): No such device
Error initializing output stream 0:0 --
Conversion failed!
$ DISPLAY=:0 sudo xvinfo
X-Video Extension version 2.2
screen #0
no adaptors present
mpv 支持 vdpau 输出
$ sudo mpv -vo help
LIBGL: Initialising glshim
Available video outputs:
vdpau : VDPAU with X11
sdl : SDL 2.0 Renderer
x11 : X11 (slow, old crap)
null : Null video output
image : Write video frames to image files
caca : libcaca
drm : Direct Rendering Manager