我使用 9 个摄像头录制音乐表演,并精确地从每个摄像头中截取音乐部分。当我尝试使用 ffmpeg 将它们以 3x3 格式布局时,视频的时间可能会相差多达一秒。将它们与 GUI 商业产品结合使用可以正常工作,但我想使用 ffmpeg 的命令行程序。这是我使用的命令:
ffmpeg -i piece13cam1.m2t -i piece13cam2.m2t -i piece13cam3.m2t -i piece13cam4.m2t -i piece13cam5.m2t -i piece13cam6.m2t -i piece13cam7.m2t -i piece13cam8.m2t -i piece13cam9.m2t -filter_complex "[0:v]scale=640:-1[a];[1:v]scale=640:-1[b];[2:v]scale=640:-1[c];[3:v]scale=640:-1[d];[4:v]scale=640:-1[e];[5:v]scale=640:-1[f];[6:v]scale=640:-1[g];[7:v]scale=640:-1[h];[8:v]scale=640:-1[i]; [0:v][a] overlay=0:0 [xb]; [xb][b] overlay=640:0 [xc];[xc][c] overlay=1280:0 [xd]; [xd][d] overlay=0:360 [xe];[xe][e] overlay=640:360 [xf];[xf][f] overlay=1280:360 [xg];[xg][g] overlay=0:720 [xh];[xh][h] overlay=640:720 [xi];[xi][i] overlay=1280:720" piece13composite.m2t
以下是运行时输出:
ffmpeg version N-82597-gd316b21 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 5.4.0 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib libavutil 55. 40.100 / 55. 40.100
libavcodec 57. 66.106 / 57. 66.106
libavformat 57. 58.100 / 57. 58.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 67.100 / 6. 67.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, mpegts, from 'piece13cam1.m2t':
Duration: 00:04:00.15, start: 1.400000, bitrate: 3984 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 384 kb/s
Input #1, mpegts, from 'piece13cam2.m2t':
Duration: 00:04:00.15, start: 1.400000, bitrate: 4033 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #1:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #1:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 384 kb/s
Input #2, mpegts, from 'piece13cam3.m2t':
Duration: 00:04:00.17, start: 1.400000, bitrate: 4069 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #2:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #2:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 384 kb/s
Input #3, mpegts, from 'piece13cam4.m2t':
Duration: 00:04:00.13, start: 1.400000, bitrate: 3906 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #3:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #3:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 384 kb/s
Input #4, mpegts, from 'piece13cam5.m2t':
Duration: 00:04:00.10, start: 1.400000, bitrate: 4409 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #4:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #4:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 384 kb/s
Input #5, mpegts, from 'piece13cam6.m2t':
Duration: 00:04:00.17, start: 1.400000, bitrate: 3357 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #5:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #5:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 384 kb/s
Input #6, mpegts, from 'piece13cam7.m2t':
Duration: 00:04:00.15, start: 1.400000, bitrate: 3623 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #6:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #6:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 384 kb/s
Input #7, mpegts, from 'piece13cam8.m2t':
Duration: 00:04:00.17, start: 1.400000, bitrate: 3422 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #7:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #7:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 384 kb/s
Input #8, mpegts, from 'piece13cam9.m2t':
Duration: 00:04:00.20, start: 1.400000, bitrate: 3693 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #8:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #8:1[0x101]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 384 kb/s
File 'piece13composite.m2t' already exists. Overwrite ? [y/N] Output #0, mpegts, to 'piece13composite.m2t':
Metadata:
encoder : Lavf57.58.100
Stream #0:0: Video: mpeg2video (Main), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 59.94 fps, 90k tbn, 59.94 tbc (default)
Metadata:
encoder : Lavc57.66.106 mpeg2video
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s
Metadata:
encoder : Lavc57.66.106 mp2
Stream mapping:
Stream #0:0 (mpeg2video) -> scale (graph 0)
Stream #0:0 (mpeg2video) -> overlay:main (graph 0)
Stream #1:0 (mpeg2video) -> scale (graph 0)
Stream #2:0 (mpeg2video) -> scale (graph 0)
Stream #3:0 (mpeg2video) -> scale (graph 0)
Stream #4:0 (mpeg2video) -> scale (graph 0)
Stream #5:0 (mpeg2video) -> scale (graph 0)
Stream #6:0 (mpeg2video) -> scale (graph 0)
Stream #7:0 (mpeg2video) -> scale (graph 0)
Stream #8:0 (mpeg2video) -> scale (graph 0)
overlay (graph 0) -> Stream #0:0 (mpeg2video)
Stream #0:1 -> #0:1 (mp2 (native) -> mp2 (native))
Press [q] to stop, [?] for help
frame= 9 fps=0.0 q=14.7 size= 464kB time=00:00:00.39 bitrate=9557.4kbits/s speed=0.793x
.....
frame=14379 fps= 37 q=31.0 Lsize= 132985kB time=00:04:00.13 bitrate=4536.7kbits/s speed=0.613x
video:109909kB audio:11257kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.754501%
我应该做些什么才能使所有 9 个视频彼此同步?谢谢。