我正在尝试使用ffmpeg
(macOS 10.12)从相机捕获视频,并使用ffplay
和rawvideo
选项将其通过管道传输到-v copy
中:>
ffmpeg -f avfoundation -pixel_format 0rgb -framerate 25 -video_size 1280x720 -i "0" -map 0:v -c copy -f rawvideo - | ffplay -f rawvideo -video_size 1280x720 -pixel_format 0rgb -i -
视频捕获效果很好,但是它会不断向侧面移动(请参阅所附的屏幕截图)。这可能是什么问题?
更新完整的ffmpeg
日志输出:
$ ffmpeg -f avfoundation -pixel_format 0rgb -framerate 25 -video_size 1280x720 -i "0" -map 0:v -c copy -f rawvideo - | ffplay -f rawvideo -video_size 1280x720 -pixel_format 0rgb -i -
ffmpeg version 4.0.2ffplay version 4.0.2 Copyright © 2003-2018 the FFmpeg developers Copyright © 2000-2018 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 56. 14.100 / 56. 14.100
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavcodec 58. 18.100 / 58. 18.100
libavdevice 58. 3.100 / 58. 3.100
libavformat 58. 12.100 / 58. 12.100
libavfilter 7. 16.100 / 7. 16.100
libavdevice 58. 3.100 / 58. 3.100
libavresample 4. 0. 0 / 4. 0. 0
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libavresample 4. 0. 0 / 4. 0. 0
libpostproc 55. 1.100 / 55. 1.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
2018-09-20 09:33:28.013 ffmpeg[45781:16452887] Error loading /Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: dlopen(/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn, 262): no suitable image found. Did find:
/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: mach-o, but wrong architecture
/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: mach-o, but wrong architecture
2018-09-20 09:33:28.013 ffmpeg[45781:16452887] Cannot find function pointer New_SHP_PlugIn for factory 834FC054-C1CC-11D6-BD01-00039315CD46 in CFBundle/CFPlugIn 0x7fe63b506d00 </Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin> (bundle, not loaded)
2018-09-20 09:33:28.069 ffplay[45782:16452888] Error loading /Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: dlopen(/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn, 262): no suitable image found. Did find:
/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: mach-o, but wrong architecture
/Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin/Contents/MacOS/SeratoVirtualAudioPlugIn: mach-o, but wrong architecture
2018-09-20 09:33:28.069 ffplay[45782:16452888] Cannot find function pointer New_SHP_PlugIn for factory 834FC054-C1CC-11D6-BD01-00039315CD46 in CFBundle/CFPlugIn 0x7f93f3c13020 </Library/Audio/Plug-Ins/HAL/SeratoVirtualAudioPlugIn.plugin> (bundle, not loaded)
[avfoundation @ 0x7fe63c000000] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, avfoundation, from '0':
Duration: N/A, start: 1054.178167, bitrate: N/A
Stream #0:0: Video: rawvideo ([0]RGB / 0x42475200), 0rgb, 1280x720, 1000k tbr, 1000k tbn, 1000k tbc
Output #0, rawvideo, to 'pipe:': 0KB vq= 0KB sq= 0B f=0/0
Metadata:
encoder : Lavf58.12.100
Stream #0:0: Video: rawvideo ([0]RGB / 0x42475200), 0rgb, 1280x720, q=2-31, 1000k tbr, 1000k tbn, 1000k tbc
Stream mapping:
Stream #0:0 -> #0:0 ©
Press [q] to stop, [?] for help
Input #0, rawvideo, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: 737280 kb/s
Stream #0:0: Video: rawvideo ([0]RGB / 0x42475200), 0rgb, 1280x720, 737280 kb/s, 25 tbr, 25 tbn, 25 tbc
frame= 16 fps=0.0 q=-1.0 size= 57600kB time=00:00:00.60 bitrate=786437.5kbits/s speed=1.frame= 29 fps= 28 q=-1.0 size= 104401kB time=00:00:01.12 bitrate=763617.4kbits/s speed=1.frame= 42 fps= 27 q=-1.0 size= 151201kB time=00:00:01.64 bitrate=755268.5kbits/s speed=1.frame= 55 fps= 26 q=-1.0 size= 198002kB time=00:00:02.16 bitrate=750939.5kbits/s speed=1.frame= 68 fps= 26 q=-1.0 size= 244802kB time=00:00:02.68 bitrate=748290.4kbits/s speed=1.av_interleaved_write_frame(): Broken pipe= 0KB sq= 0B f=0/0
Error writing trailer of pipe:: Broken pipe
frame= 69 fps= 26 q=-1.0 Lsize= 247650kB time=00:00:02.72 bitrate=745863.6kbits/s speed=1.01x
video:248402kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Exiting normally, received signal 2.
答案 0 :(得分:1)
看起来像对齐/填充问题。由于ffplay似乎没有选项,因此请为ffplay尝试使用更大的视频宽度,而不是像1282或更大的1280。
答案 1 :(得分:0)
看起来avfoundation设备正在将每个额外的32个字节填充到每个数据包上,从而导致步幅的逐渐变化,表现为水平对齐的逐渐偏移。
对流进行转码会强制执行解码,从而摆脱了填充。
Frame rate very high for a muxer not efficiently supporting it
的警告与该问题无关。 avfoundation
设备正在注册一百万(!)的帧速率,这对于恒定帧速率混合器是一个问题,因为ffmpeg会尝试复制帧以在输出中满足该速率。 -vsync vfr
避免了这个问题。