使用 FFmpeg 同步两个具有不同帧速率的视频

使用 FFmpeg 同步两个具有不同帧速率的视频

这应该很容易。实际上,这可能很容易。我可能只是笨了。我有两个视频,同时拍摄,但用两个不同的相机。一个视频是 1920x1080@60,另一个是[电子邮件保护]。我想制作一个视频,让两个视频同时播放(画中画、分屏,等等;这不是问题)。当我这样做时,其中一个视频比另一个视频早结束几秒钟。我确信这是因为帧速率不同,但 -framerate 或 -r 的组合,无论是作为输入还是输出参数(或两者),都无法为我提供同步的视频。它们开始时同步,但最后有几秒钟的差异。

如上所述,我尝试了许多方法。以下是一些测试(不要介意实际值;大多数情况下,这些只是试图看看效果如何):

ffmpeg -i %1 -r %outrate%-c:v libx264 -profile:v high -level 4.1 -preset veryfast -y %输出%

ffmpeg -i %1 -filter:v“setpts = 0.25 * PTS”-c:v libx264 -profile:v high -level 4.1 -preset veryfast -y%输出%

ffmpeg -r %inrate% -i %1 -r %outrate% -c:v libx264 -profile:v high -level 4.1 -preset veryfast -shortest -y %output%

以下是每个文件的信息:

ffmpeg version N-91330-ga990184007 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 18.102 / 56. 18.102
  libavcodec     58. 20.103 / 58. 20.103
  libavformat    58. 17.100 / 58. 17.100
  libavdevice    58.  4.101 / 58.  4.101
  libavfilter     7. 25.100 /  7. 25.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000020412f7a040] st: 0 edit list: 1 Missing key frame while searching for timestamp: 1000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000020412f7a040] st: 0 edit list 1 Cannot find an index entry before timestamp: 1000.
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '60fps.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2015-01-01T00:04:15.000000Z
  Duration: 00:05:40.00, start: 0.000000, bitrate: 31673 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 29717 kb/s, 60 fps, 60 tbr, 60k tbn, 120k tbc (default)
    Metadata:
      creation_time   : 2015-01-01T00:04:15.000000Z
      handler_name    : iCatch Alias Data Handler
      encoder         : iCatch AVCC
    Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      creation_time   : 2015-01-01T00:04:15.000000Z
      handler_name    : iCat Alias Data Handler
[avi @ 0000020413a3e280] non-interleaved AVI
Guessed Channel Layout for Input Stream #1.1 : mono
Input #1, avi, from '29fps.avi':
  Duration: 00:05:04.36, start: 0.000000, bitrate: 7266 kb/s
    Stream #1:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 640x480, 7071 kb/s, 29.85 fps, 29.85 tbr, 29.85 tbn, 29.85 tbc
    Stream #1:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, mono, s16, 128 kb/s
At least one output file must be specified

我知道这很简单。但是我就是想不出来,我找了好几天也没找到。我的功夫太差了。我向你鞠躬。

相关内容