ffmpeg 无法在 Mac 上为视频添加字幕

ffmpeg 无法在 Mac 上为视频添加字幕

我使用这个命令

fmpeg -i out.mp4 -i drbraun.ass -map 0 -map 1 -c:v copy -c:s mov_text out1.mp4

输出结果如下,但输出文件中没有字幕。我猜可能是 Mac OS 有问题,但不确定。

ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.102 / 57. 24.102
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 31.100 /  6. 31.100
  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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.25.100
  Duration: 00:07:28.94, start: 0.023220, bitrate: 1400 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1260 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 131 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, ass, from 'drbraun.ass':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Subtitle: ass
Output #0, mp4, to 'out1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.25.100
    Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1260 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 30k tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc57.24.102 aac
    Stream #0:2: Subtitle: mov_text ([8][0][0][0] / 0x0008)
    Metadata:
      encoder         : Lavc57.24.102 mov_text
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
  Stream #1:0 -> #0:2 (ass (native) -> mov_text (native))
Press [q] to stop, [?] for help
frame=  321 fps=0.0 q=-1.0 size=    1961kB time=00:00:11.40 bitrate=1408.9kbits/frame=  636 fps=635 q=-1.0 size=    3807kB time=00:00:25.40 bitrate=1227.7kbits/frame=  984 fps=655 q=-1.0 size=    5634kB time=00:00:37.40 bitrate=1234.0kbits/frame= 1321 fps=660 q=-1.0 size=    7625kB time=00:00:45.40 bitrate=1375.8kbits/frame= 1426 fps=550 q=-1.0 size=    8196kB time=00:00:52.40 bitrate=1281.3kbits/frame= 1738 fps=562 q=-1.0 size=    9979kB time=00:01:00.40 bitrate=1353.5kbits/frame= 2011 fps=559 q=-1.0 size=   11429kB time=00:01:08.40 bitrate=1368.8kbits/frame= 2284 fps=558 q=-1.0 size=   12975kB time=00:01:16.40 bitrate=1391.2kbits/frame= 2555 fps=556 q=-1.0 size=   14607kB time=00:01:28.40 bitrate=1353.6kbits/frame= 2858 fps=561 q=-1.0 size=   16317kB time=00:01:36.40 bitrate=1386.6kbits/frame= 3135 fps=560 q=-1.0 size=   17986kB time=00:01:48.40 bitrate=1359.2kbits/frame= 3420 fps=561 q=-1.0 size=   19454kB time=00:01:56.40 bitrate=1369.1kbits/frame= 3703 fps=561 q=-1.0 size=   21027kB time=00:02:08.40 bitrate=1341.5kbits/frame= 3966 fps=558 q=-1.0 size=   22607kB time=00:02:16.40 bitrate=1357.7kbits/frame= 4284 fps=563 q=-1.0 size=   24283kB time=00:02:26.40 bitrate=1358.8kbits/frame= 4556 fps=562 q=-1.0 size=   25806kB time=00:02:32.40 bitrate=1387.2kbits/frame= 4833 fps=562 q=-1.0 size=   27315kB time=00:02:44.40 bitrate=1361.1kbits/frame= 5088 fps=559 q=-1.0 size=   28772kB time=00:02:50.40 bitrate=1383.2kbits/frame= 5389 fps=561 q=-1.0 size=   30455kB time=00:03:00.40 bitrate=1383.0kbits/frame= 5638 fps=558 q=-1.0 size=   31877kB time=00:03:10.40 bitrate=1371.5kbits/frame= 5900 fps=556 q=-1.0 size=   33377kB time=00:03:18.40 bitrate=1378.1kbits/frame= 6232 fps=561 q=-1.0 size=   35011kB time=00:03:28.40 bitrate=1376.2kbits/frame= 6559 fps=565 q=-1.0 size=   36716kB time=00:03:40.40 bitrate=1364.7kbits/frame= 6881 fps=568 q=-1.0 size=   38671kB time=00:03:50.40 bitrate=1375.0kbits/frame= 7188 fps=570 q=-1.0 size=   40403kB time=00:04:00.40 bitrate=1376.8kbits/frame= 7451 fps=568 q=-1.0 size=   41935kB time=00:04:10.40 bitrate=1371.9kbits/frame= 7731 fps=568 q=-1.0 size=   43376kB time=00:04:18.40 bitrate=1375.2kbits/frame= 7978 fps=565 q=-1.0 size=   44919kB time=00:04:26.40 bitrate=1381.3kbits/frame= 8239 fps=564 q=-1.0 size=   46256kB time=00:04:38.40 bitrate=1361.1kbits/frame= 8505 fps=563 q=-1.0 size=   47800kB time=00:04:44.40 bitrate=1376.8kbits/frame= 8790 fps=563 q=-1.0 size=   49697kB time=00:04:54.40 bitrate=1382.9kbits/frame= 9048 fps=561 q=-1.0 size=   51574kB time=00:05:06.40 bitrate=1378.9kbits/frame= 9298 fps=559 q=-1.0 size=   53226kB time=00:05:14.40 bitrate=1386.8kbits/frame= 9560 fps=558 q=-1.0 size=   54818kB time=00:05:22.40 bitrate=1392.9kbits/frame= 9781 fps=555 q=-1.0 size=   56118kB time=00:05:30.40 bitrate=1391.4kbits/frame=10005 fps=552 q=-1.0 size=   57370kB time=00:05:36.40 bitrate=1397.1kbits/frame=10255 fps=551 q=-1.0 size=   58584kB time=00:05:42.40 bitrate=1401.6kbits/frame=10512 fps=550 q=-1.0 size=   59571kB time=00:05:52.40 bitrate=1384.8kbits/frame=10803 fps=550 q=-1.0 size=   60562kB time=00:06:00.40 bitrate=1376.6kbits/frame=11066 fps=550 q=-1.0 size=   61889kB time=00:06:10.40 bitrate=1368.8kbits/frame=11337 fps=550 q=-1.0 size=   63824kB time=00:06:18.40 bitrate=1381.7kbits/frame=11582 fps=548 q=-1.0 size=   65419kB time=00:06:28.40 bitrate=1379.8kbits/frame=11819 fps=546 q=-1.0 size=   66744kB time=00:06:34.40 bitrate=1386.3kbits/frame=12043 fps=544 q=-1.0 size=   67893kB time=00:06:42.40 bitrate=1382.2kbits/frame=12298 fps=543 q=-1.0 size=   69339kB time=00:06:50.40 bitrate=1384.1kbits/frame=12558 fps=543 q=-1.0 size=   70924kB time=00:07:00.40 bitrate=1382.0kbits/frame=12800 fps=541 q=-1.0 size=   72710kB time=00:07:08.40 bitrate=1390.4kbits/frame=13121 fps=543 q=-1.0 size=   74392kB time=00:07:18.40 bitrate=1390.1kbits/frame=13399 fps=544 q=-1.0 size=   75567kB time=00:07:27.00 bitrate=1384.9kbits/frame=13452 fps=543 q=-1.0 Lsize=   76696kB time=00:07:28.93 bitrate=1399.5kbits/s speed=18.1x
video:69072kB audio:7142kB subtitle:4kB other streams:0kB global headers:0kB muxing overhead: 0.627264%

谁能找出原因?

答案1

从此链接https://trac.ffmpeg.org/wiki/HowToBurnSubtitlesIntoVideo,我发现这libass是处理字幕所必需的。

因此,我只需重新安装 ffmpegbrew install ffmpeg --with-libass

然后使用更简单的命令将字幕与视频合并,

ffmpeg -i in.mp4 -vf subtitles=sub.ass out.mp4

并且它有效。

相关内容