다음 질문을 발견하고 mp4 비디오를 내 카메라로 보내려고 했습니다. ffmpeg가 Ubuntu의/dev/video0에 비디오를 보내는 방법이 있습니까?
다음 명령을 사용했습니다.
ffmpeg -re -i fakezoom.mp4 -map 0:v -f h264 /dev/video0
Ubuntu에 따르면 mp4의 파일 속성은 H.264, 초당 30프레임, 414kbps 비트 전송률입니다.
명령을 실행하면 다음과 같은 출력이 표시됩니다.
ffmpeg -re -i fakezoom.mp4 -map 0:v -f h264 /dev/video0
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
WARNING: library configuration mismatch
avcodec configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-liblensfun --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x56370afc9700] st: 0 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x56370afc9700] st: 0 edit list 1 Cannot find an index entry before timestamp: 0.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'fakezoom.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: mp41avc1
creation_time : 2021-04-20T09:39:14.000000Z
encoder : vlc 3.0.9.2 stream output
encoder-eng : vlc 3.0.9.2 stream output
Duration: 00:13:18.78, start: 0.000000, bitrate: 416 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, unknown/bt709/bt709), 1280x720 [SAR 1:1 DAR 16:9], 414 kb/s, 17.91 fps, 17.67 tbr, 90k tbn, 60 tbc (default)
Metadata:
creation_time : 2021-04-20T09:39:14.000000Z
handler_name : VideoHandler
File '/dev/video0' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x56370afce880] using SAR=1/1B time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
[libx264 @ 0x56370afce880] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x56370afce880] profile High, level 3.1
Output #0, h264, to '/dev/video0':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: mp41avc1
encoder : Lavf58.29.100
Stream #0:0(eng): Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 17.67 fps, 17.67 tbn, 17.67 tbc (default)
Metadata:
creation_time : 2021-04-20T09:39:14.000000Z
handler_name : VideoHandler
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
av_interleaved_write_frame(): Invalid argumente=00:00:02.88 bitrate= 665.2kbits/s dup=0 drop=1 speed=0.408x
Error writing trailer of /dev/video0: Invalid argument
frame= 121 fps= 16 q=27.0 Lsize= 258kB time=00:00:03.22 bitrate= 654.2kbits/s dup=0 drop=1 speed=0.432x
video:258kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
[libx264 @ 0x56370afce880] frame I:1 Avg QP:17.14 size: 45994
[libx264 @ 0x56370afce880] frame P:31 Avg QP:20.92 size: 9074
[libx264 @ 0x56370afce880] frame B:89 Avg QP:22.87 size: 853
[libx264 @ 0x56370afce880] consecutive B-frames: 0.8% 3.3% 0.0% 95.9%
[libx264 @ 0x56370afce880] mb I I16..4: 7.1% 77.3% 15.7%
[libx264 @ 0x56370afce880] mb P I16..4: 0.2% 2.1% 0.5% P16..4: 18.5% 7.1% 3.1% 0.0% 0.0% skip:68.4%
[libx264 @ 0x56370afce880] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 10.1% 0.4% 0.1% direct: 0.3% skip:89.1% L0:48.1% L1:48.4% BI: 3.6%
[libx264 @ 0x56370afce880] 8x8 transform intra:76.2% inter:67.0%
[libx264 @ 0x56370afce880] coded y,uvDC,uvAC intra: 57.3% 80.2% 42.2% inter: 3.4% 5.5% 0.1%
[libx264 @ 0x56370afce880] i16 v,h,dc,p: 20% 15% 10% 55%
[libx264 @ 0x56370afce880] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 13% 12% 7% 9% 11% 7% 7% 6%
[libx264 @ 0x56370afce880] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 18% 10% 6% 11% 11% 9% 6% 6%
[libx264 @ 0x56370afce880] i8c dc,h,v,p: 46% 20% 21% 13%
[libx264 @ 0x56370afce880] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x56370afce880] ref P L0: 56.5% 16.3% 20.0% 7.2%
[libx264 @ 0x56370afce880] ref B L0: 75.3% 20.1% 4.6%
[libx264 @ 0x56370afce880] ref B L1: 98.8% 1.2%
[libx264 @ 0x56370afce880] kb/s:470.92
Conversion failed!
대화 실패로 끝나지만 다음과 같은 이상한 메시지도 포함되어 있습니다.
av_interleaved_write_frame(): Invalid argumente=00:00:02.88 bitrate= 665.2kbits/s dup=0 drop=1 speed=0.408x
Error writing trailer of /dev/video0: Invalid argument
내가 잘못하고 있는 게 있나요?
v4l2-ctl --list-devices
출력:
OBS Video Source (platform:v4l2loopback-000):
/dev/video10
UVC Camera (046d:081b) (usb-0000:02:00.0-5):
/dev/video0
/dev/video1
내가 거기에서 사용하고 있는 루프백 때문일 수도 있습니까? 나는 가끔 카메라를 올바른 방식으로 사용하고 싶을 때 녹색 화면을 시뮬레이션하고 가상 배경을 추가하기 위해 /dev/video0을 video10에 매핑하는 프로그램을 사용합니다.
누구든지 그 문제를 해결하는 방법을 알고 있습니까?
답변1
연결된 답변은 "가짜 카메라"를 만드는 방법을 보여줍니다. 따라서 선택한 비디오를 /dev/video*
실제 장치에서 아직 사용하지 않는 장치로 보낼 수 있습니다.
기존 장치에 비디오를 공급할 필요가 없습니다. 이러한 장치는 비디오만 출력하므로 어쨌든 임의의 비디오를 카메라에 공급할 수 있을지 의문입니다.
실행하면 현재 사용하지 않는 ID 번호(예: )를 사용하여 sudo modprobe v4l2loopback
새 ID를 만들어야 합니다 . 그런 다음 다음을 실행하십시오./dev/video
/dev/video2
ffmpeg -re -i fakezoom.mp4 -map 0:v -f v4l2 /dev/video2
-f h264
귀하의 질문에서 as가 로 변경되었음을 확인하십시오 -f v4l2
.