我正在尝试使用 ffmpeg 将图像流式传输到 v4l2loopback,但似乎只有png
s 有效。这是我正在使用的命令,其中<image>
是图像的路径,/dev/video63
是 v4l2loopback 设备:
ffmpeg -stream_loop -1 -re -i <image> -f v4l2 -vcodec rawvideo -pix_fmt yuv420p /dev/video63
当<image>
是 png 时,一切都运行正常,但当<image>
是 jpg 时,它只会流式传输一帧然后退出,尽管 设置为-stream_loop
。-1
当我尝试使用 jpg 时,这是我从 ffmpeg 输出的:
ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, image2, from '<image>':
Duration: 00:00:00.04, start: 0.000000, bitrate: 13439 kb/s
Stream #0:0: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> rawvideo (native))
Press [q] to stop, [?] for help
[swscaler @ 0x55a4ab7cb880] deprecated pixel format used, make sure you did set range correctly
Output #0, video4linux2,v4l2, to '/dev/video63':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 276480 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc58.91.100 rawvideo
frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=0.941x
video:1350kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
答案1
对于图像使用-loop
:
ffmpeg -loop 1 -re -i <image> -f v4l2 -pix_fmt yuv420p /dev/video63
不需要,-vcodec rawvideo
因为-f v4l2
会自动选择那个。