ffmpeg:.ogv 到 .mp4 - 音频视频不同步

ffmpeg:.ogv 到 .mp4 - 音频视频不同步

我有一个 .ogv 格式的视频,想将其转换为 .mp4,以便可以将其上传到 youtube。

我正在努力ffmpeg实现它:

ffmpeg -i *.ogv -acodec libmp3lame -vcodec libx264 -crf 18 Windup-demo.mp4

转换后,视频不同步 - 音频听起来不错,但视频似乎很匆忙。原始视频使用 RecordMyDesktop 录制,每秒 5 帧,音频每秒 48000 个样本立体声。

我可以尝试什么来修复此问题?

(只要能将视频发布到 YouTube 上,我就会接受。)

我尝试过ffmpeg -r 5 -i Windup-2.5.0-shortDemo-04.ogv -acodec libmp3lame -vcodec h264 -r 5 Windup-demoX.mp4,但没有成功——同步变得更糟了。

编辑:我已尝试过ffmpeg -r 5 -i Windup-2.5.0-shortDemo-04.ogv -acodec libmp3lame -vcodec libx264 -r 5 -vsync cfr Windup-demoX.mp4vfr没有成功。

所以问题归结为“如何强制 ffmpeg 使用正确的输出帧速率。

我也尝试过静态构建http://johnvansickle.com/ffmpeg/。我尝试使用 将其编码回 OGV -vcodec libtheora,但由于“无效选项”而失败,没弄清楚问题出在哪里。

我也尝试过ffmpeg -loglevel info -r:v 5 -framerate 5 -i Windup-2.5.0-shortDemo-04.ogv -acodec copy -vcodec h264 -r 15 Windup-demoX.mp4-framerate应该可以用作输入参数,但它显示“未找到选项帧速率”。对于输出,它可以工作。

$ ffmpeg -i Windup-2.5.0-shortDemo-04.ogv -acodec libmp3lame -vcodec libx264 -crf 18 Windup-demoX.mp4
ffmpeg version N-79139-gde1a0d4 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.1)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
  libavutil      55. 19.100 / 55. 19.100
  libavcodec     57. 30.100 / 57. 30.100
  libavformat    57. 29.101 / 57. 29.101
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 40.102 /  6. 40.102
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.
Input #0, ogg, from 'Windup-2.5.0-shortDemo-04.ogv':
  Duration: 00:06:13.00, start: 0.000000, bitrate: 1134 kb/s
    Stream #0:0: Data: none
    Stream #0:1: Video: theora, yuv420p, 1920x1056 [SAR 1:1 DAR 20:11], 5 tbr, 5 tbn, 5 tbc
    Metadata:
      RECORDMYDESKTOP : 0.3.8.1
    Stream #0:2: Audio: vorbis, 48000 Hz, stereo, fltp, 499 kb/s
[libx264 @ 0x30beec0] using SAR=1/1
[libx264 @ 0x30beec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x30beec0] profile High, level 4.0
[libx264 @ 0x30beec0] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=5 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'Windup-demoX.mp4':
  Metadata:
    encoder         : Lavf57.29.101
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1056 [SAR 1:1 DAR 20:11], q=-1--1, 5 fps, 10240 tbn, 5 tbc
    Metadata:
      RECORDMYDESKTOP : 0.3.8.1
      encoder         : Lavc57.30.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: mp3 (libmp3lame) (i[0][0][0] / 0x0069), 48000 Hz, stereo, fltp
    Metadata:
      encoder         : Lavc57.30.100 libmp3lame
Stream mapping:
  Stream #0:1 -> #0:0 (theora (native) -> h264 (libx264))
  Stream #0:2 -> #0:1 (vorbis (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.trate=  55.0kbits/s speed=  35x
[ogg @ 0x30b7d60] Broken file, non-keyframe not correctly marked.
    Last message repeated 3 times
[ogg @ 0x30b7d60] Broken file, non-keyframe not correctly marked.e=  84.6kbits/s dup=18 drop=0 speed=29.4x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 141.2kbits/s dup=46 drop=0 speed=22.5x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 179.3kbits/s dup=50 drop=0 speed=23.3x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 487.8kbits/s dup=51 drop=0 speed=21.4x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 518.6kbits/s dup=55 drop=0 speed=21.2x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 494.7kbits/s dup=93 drop=0 speed=  21x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 457.5kbits/s dup=93 drop=0 speed=21.8x
    Last message repeated 1 times
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 409.8kbits/s dup=93 drop=0 speed=23.2x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 375.2kbits/s dup=93 drop=0 speed=24.2x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 391.1kbits/s dup=124 drop=0 speed=23.2x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 389.7kbits/s dup=147 drop=0 speed=23.1x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 392.5kbits/s dup=193 drop=0 speed=22.5x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 377.9kbits/s dup=195 drop=0 speed=22.8x
    Last message repeated 1 times
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 368.9kbits/s dup=195 drop=0 speed=23.1x
    Last message repeated 1 times
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 355.5kbits/s dup=195 drop=0 speed=23.5x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 404.0kbits/s dup=244 drop=0 speed=22.5x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 392.9kbits/s dup=284 drop=0 speed=22.6x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 378.4kbits/s dup=284 drop=0 speed=22.9x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 371.0kbits/s dup=318 drop=0 speed=  23x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 364.4kbits/s dup=366 drop=0 speed=22.9x
    Last message repeated 1 times
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 351.5kbits/s dup=366 drop=0 speed=23.4x
[ogg @ 0x30b7d60] Broken file, keyframe not correctly marked.itrate= 341.4kbits/s dup=366 drop=0 speed=23.7x
frame= 1026 fps= 63 q=-1.0 Lsize=   16452kB time=00:06:12.51 bitrate= 361.8kbits/s dup=400 drop=0 speed=22.8x
video:10602kB audio:5820kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.180144%
[libx264 @ 0x30beec0] frame I:9     Avg QP: 3.21  size:226053
[libx264 @ 0x30beec0] frame P:317   Avg QP:12.28  size: 26964
[libx264 @ 0x30beec0] frame B:700   Avg QP:17.44  size:   391
[libx264 @ 0x30beec0] consecutive B-frames:  8.3%  1.6%  2.0% 88.1%
[libx264 @ 0x30beec0] mb I  I16..4: 72.1% 10.0% 17.9%
[libx264 @ 0x30beec0] mb P  I16..4:  4.8%  0.4%  1.8%  P16..4:  3.3%  0.7%  0.5%  0.0%  0.0%    skip:88.5%
[libx264 @ 0x30beec0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  1.4%  0.0%  0.0%  direct: 0.1%  skip:98.4%  L0:31.6% L1:67.9% BI: 0.5%
[libx264 @ 0x30beec0] 8x8 transform intra:7.4% inter:68.2%
[libx264 @ 0x30beec0] coded y,uvDC,uvAC intra: 18.2% 26.7% 23.3% inter: 0.5% 1.3% 1.1%
[libx264 @ 0x30beec0] i16 v,h,dc,p: 57% 42%  0%  0%
[libx264 @ 0x30beec0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 21% 51%  1%  1%  1%  1%  1%  2%
[libx264 @ 0x30beec0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 32% 19%  3%  4%  4%  5%  3%  5%
[libx264 @ 0x30beec0] i8c dc,h,v,p: 54% 34% 12%  1%
[libx264 @ 0x30beec0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x30beec0] ref P L0: 83.0%  2.9%  9.8%  4.4%
[libx264 @ 0x30beec0] ref B L0: 83.0% 15.4%  1.5%
[libx264 @ 0x30beec0] ref B L1: 91.9%  8.1%
[libx264 @ 0x30beec0] kb/s:423.23

答案1

我最后做的事有点荒唐。

我在 VLC 中播放了视频,然后使用 RecordMyDesktop 以 30 FPS 和“全帧”选项再次录制。这个视频的音频效果很差,但 YouTube 接受了。

然后我上传了另一个版本,视频不同步但音频很好。然后我使用 YouTube 编辑器将这两个版本混合在一起。结果是有点“视障”,但至少不用重新录制。

我仍在接受任何更好的事物。

相关内容