最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】ffmpeg嵌入硬编码烧录ass字幕到视频中即字幕成为视频内容本身

视频 crifan 2439浏览 0评论
折腾:
【已解决】Mac中用ffmpeg调整mp4默认字幕为中文
期间,发现软字幕的话,
TunesKit Video Cutter还是不显示字幕
所以尝试去直接burned in字幕。
再去试试:
➜  ffmpeg_edit_subtitle ffmpeg -i CTT_Folge_01_CH_Subs_DefaultZhcnButNotShow.mp4 -vf ass=subtitle.ass burnedInAssSubtitle.mp4
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.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-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-nonfree
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'CTT_Folge_01_CH_Subs_DefaultZhcnButNotShow.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2018-10-13T03:27:31.000000Z
    encoder         : HandBrake 1.1.2 2018090500
  Duration: 00:26:52.03, start: 0.000000, bitrate: 1762 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1599 kb/s, 25 fps, 25 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2018-10-13T03:27:31.000000Z
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 157 kb/s (default)
    Metadata:
      creation_time   : 2018-10-13T03:27:31.000000Z
      handler_name    : Stereo
    Stream #0:2(zho): Subtitle: mov_text (tx3g / 0x67337874), 1280x108, 0 kb/s (default)
    Metadata:
      creation_time   : 2018-10-13T03:27:31.000000Z
      handler_name    : SubtitleHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[Parsed_ass_0 @ 0x7f9f7350a980] Shaper: FriBidi 0.19.7 (SIMPLE) HarfBuzz-ng 1.9.0 (COMPLEX)
[Parsed_ass_0 @ 0x7f9f7350a980] Using font provider coretext
[Parsed_ass_0 @ 0x7f9f7350a980] Added subtitle file: 'subtitle.ass' (2 styles, 317 events)
[libx264 @ 0x7f9f73810c00] using SAR=1/1
[libx264 @ 0x7f9f73810c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f9f73810c00] profile High, level 3.1
[libx264 @ 0x7f9f73810c00] 264 - core xxx e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - 
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=6 lookahead_threads=1 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=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'burnedInAssSubtitle.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.12.100
    Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      creation_time   : 2018-10-13T03:27:31.000000Z
      handler_name    : VideoHandler
      encoder         : Lavc58.18.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2018-10-13T03:27:31.000000Z
      handler_name    : Stereo
      encoder         : Lavc58.18.100 aac
[Parsed_ass_0 @ 0x7f9f7350a980] fontselect: (Arial, 400, 0) -> /Library/Fonts/Arial.ttf, -1, ArialMT
[Parsed_ass_0 @ 0x7f9f7350a980] Glyph 0x5927 not found, selecting one more font for (Arial, 400, 0)
[Parsed_ass_0 @ 0x7f9f7350a980] fontselect: (Arial, 400, 0) -> /System/Library/Fonts/PingFang.ttc, -1, PingFangSC-Regular
frame= 1506 fps= 18 q=28.0 size=   15616kB time=00:01:00.33 bitrate=2120.4kbits/s speed=0.707x
然后感觉是每一帧在处理:
-》看来肯定是内嵌入字幕了。
而且:
[Parsed_ass_0 @ 0x7f9f7350a980] fontselect: (Arial, 400, 0) -> /System/Library/Fonts/PingFang.ttc, -1, PingFangSC-Regular
选择的了字体,应该是字幕的字体。
终于处理完毕了:
[Parsed_ass_0 @ 0x7f9f7350a980] fontselect: (Arial, 400, 0) -> /System/Library/Fonts/PingFang.ttc, -1, PingFangSC-Regular
frame=40300 fps= 26 q=-1.0 Lsize=  390744kB time=00:26:51.98 bitrate=1985.7kbits/s speed=1.03x
video:364281kB audio:25285kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.302408%
[libx264 @ 0x7f9f73810c00] frame I:286   Avg QP:18.54  size: 74555
[libx264 @ 0x7f9f73810c00] frame P:12524 Avg QP:21.81  size: 17811
[libx264 @ 0x7f9f73810c00] frame B:27490 Avg QP:24.86  size:  4679
[libx264 @ 0x7f9f73810c00] consecutive B-frames:  4.3%  9.0% 15.9% 70.8%
[libx264 @ 0x7f9f73810c00] mb I  I16..4: 27.5% 20.0% 52.5%
[libx264 @ 0x7f9f73810c00] mb P  I16..4:  6.8%  5.3%  3.6%  P16..4: 41.2% 11.6%  4.9%  0.0%  0.0%    skip:26.7%
[libx264 @ 0x7f9f73810c00] mb B  I16..4:  0.8%  0.5%  0.5%  B16..8: 34.0%  3.5%  0.6%  direct: 1.7%  skip:58.4%  L0:46.4% L1:48.9% BI: 4.7%
[libx264 @ 0x7f9f73810c00] 8x8 transform intra:31.4% inter:59.0%
[libx264 @ 0x7f9f73810c00] coded y,uvDC,uvAC intra: 38.8% 64.6% 20.7% inter: 7.8% 11.6% 1.2%
[libx264 @ 0x7f9f73810c00] i16 v,h,dc,p: 29% 24% 14% 32%
[libx264 @ 0x7f9f73810c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 19% 33%  4%  4%  4%  4%  4%  4%
[libx264 @ 0x7f9f73810c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 17% 14%  8%  9%  9%  9%  7%  6%
[libx264 @ 0x7f9f73810c00] i8c dc,h,v,p: 52% 21% 21%  6%
[libx264 @ 0x7f9f73810c00] Weighted P-Frames: Y:1.2% UV:0.5%
[libx264 @ 0x7f9f73810c00] ref P L0: 67.4%  8.2% 16.9%  7.5%  0.0%
[libx264 @ 0x7f9f73810c00] ref B L0: 87.7%  9.6%  2.7%
[libx264 @ 0x7f9f73810c00] ref B L1: 96.6%  3.4%
[libx264 @ 0x7f9f73810c00] kb/s:1851.23
[aac @ 0x7f9f73812400] Qavg: 244.729
去看看处理的后的视频的字幕,是可以了:
【总结】
此处用ffmpeg,嵌入=burned in=集成=把字幕变成视频内容本身=视频播放器不可以关闭此字幕了
具体办法是:
前提
  • 确保是ass字幕
    • 【已解决】ffmpeg从mp4视频提取出srt和ass字幕文件
  • 确保ffmpeg安装了libass
    • 【已解决】Mac中尝试给mp4内嵌字幕出错:AVFilterGraph No such filter ass
    • 【已解决】Mac中brew reinstall ffmpeg出错:Error: Calling keg_only :provided_pre_mountain_lion is disabled! There is no replacement
步骤:
ffmpeg -i video_file.mp4 -vf ass=subtitle.ass burnedInAssSubtitle.mp4
即可。

转载请注明:在路上 » 【已解决】ffmpeg嵌入硬编码烧录ass字幕到视频中即字幕成为视频内容本身

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.176 seconds, using 22.08MB memory