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

【已解决】Mac中用ffmpeg调整mp4默认字幕为中文

Mac crifan 1622浏览 0评论
折腾:
【已解决】Mac中找软件编辑mp4视频的默认字幕为中文
期间,参考:
Mac系统下制作视频字幕用什么软件? – 知乎
或许可以用iffmpeg直接调整字幕?
ffmpeg 调整字幕
通过 FFMPEG,将字幕“烧进”MP4视频中 – 面朝阳光,心向大海 的专栏 – CSDN博客
ffmpeg视频合并、格式转换、截图
https://gist.github.com/ameizi/9d5572a25063790db5fb
video – ffmpeg将字幕轨道设置为默认
一看就是从别处 估计是stackoverflow翻译过来的
ffmpeg的中文文档
https://www.longqi.cf/tools/2015/02/13/ffmpegcn/
ffmpeg set default subtitle
找到了原贴:
video – ffmpeg set subtitles track as default – Stack Overflow
和我此处不完全一样:
我是希望:
可以检测出字幕有哪些
然后设置默认字幕
所以先要去解决最基本的问题:
【已解决】ffmpeg查看视频的基本信息包括字幕信息
那或许可以试试:
把字幕提取出来,然后集成进去视频中?
所以再去:
【已解决】ffmpeg从mp4视频提取出srt和ass字幕文件
嵌入字幕之前去看看参数含义
ffmpeg manual
ffmpeg Documentation
Documentation
https://www.ffmpeg.org/documentation.html
ffmpeg Documentation
FFmpeg Utilities Documentation
FFmpeg Codecs Documentation
看看别人示例:
ffmpeg -i video.mkv -vf subtitles=subtitle.srt -codec:a copy output.mkv
中的参数的含义
“-vf filtergraph (output)
Create the filtergraph specified by filtergraph and use it to filter the stream.
This is an alias for -filter:v, see the -filter option.”
-codec:a
查到的都是audio啊
为何此处subtitle处理成audio了??
好像后续的copy指的是:
video和audio,和subtitle都是copy?
算了,直接去试试效果如何。
➜  ffmpeg_edit_subtitle ffmpeg -i CTT_Folge_01_CH_Subs_DefaultZhcnButNotShow.mp4 -vf subtitles=subtitle.srt -codec:a copy burnedInSubtutle.mp4
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.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.001333, 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 (copy)
Press [q] to stop, [?] for help
[AVFilterGraph @ 0x7fc399d0a980] No such filter: 'subtitles'
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!
➜  ffmpeg_edit_subtitle
出错了:
[AVFilterGraph @ 0x7fc399d0a980] No such filter: ‘subtitles’
试试软字幕:
【已解决】ffmpeg集成srt字幕到视频的字幕流中即软字幕
TunesKit Video Cutter还是不显示字幕
问题依旧:TunesKit Video Cutter还是不显示字幕
期间出现:
【已解决】Mac中尝试给mp4内嵌字幕出错:AVFilterGraph No such filter ass
然后继续:
【已解决】ffmpeg嵌入硬编码烧录ass字幕到视频中即字幕成为视频内容本身
此处嵌入字幕虽然可以,但是字体太尼玛大了,且也没有背景色。
然后可以抽空再去参考:
How to Add Font size in subtitles in ffmpeg video filter – Stack Overflow
ffmpeg -i video.mp4 -vf "subtitles=subs.srt:force_style='Fontsize=24,PrimaryColour=&H0000ff&'" -c:a copy output.mp4
如果想要嵌入字幕时,同时设置字体大小等style。
【后记1】
不过后来换用另外的办法:
【已解决】调节ass字幕配置字幕字体大小和背景色再用ffmpeg嵌入视频中

转载请注明:在路上 » 【已解决】Mac中用ffmpeg调整mp4默认字幕为中文

发表我的评论
取消评论

表情

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

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