使用 ffmpeg 将 .mkv 转换为 .mp4,同时保留硬嵌入的字幕

使用 ffmpeg 将 .mkv 转换为 .mp4,同时保留硬嵌入的字幕

我正在尝试将 mkv 视频转换为 mp4,同时保留硬嵌入的字幕。以下是附加信息 - 有人知道我应该使用哪个命令来实现这个功能吗?

到目前为止,我已经尝试过这些命令,它们成功转换为 mp4,但丢失了字幕:

  • ffmpeg -i <input-mkv> -c:a copy -c:s mov_text <output-mp4>
  • ffmpeg -i <input-mkv> -c copy -c:s mov_text <output-mp4>
  • ffmpeg -i <input-mkv> -c:a copy -c:s mov_text -x265-params crf=25 <output-mp4>

ffprobe:

$ ffprobe -i "[ENG SUB] 210313 IZ*ONE [ONE, THE STORY] - Day 1.mkv"
ffprobe version 4.3.1 Copyright (c) 2007-2020 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.27)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_4 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, matroska,webm, from '[ENG SUB] 210313 IZ*ONE [ONE, THE STORY] - Day 1.mkv':
  Metadata:
    encoder         : libebml v1.4.1 + libmatroska v1.6.2
    creation_time   : 2021-03-15T04:54:47.000000Z
  Duration: 04:05:30.73, start: 0.000000, bitrate: 6177 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
    Metadata:
      BPS-eng         : 5860392
      DURATION-eng    : 04:05:30.716000000
      NUMBER_OF_FRAMES-eng: 441480
      NUMBER_OF_BYTES-eng: 10790971990
      _STATISTICS_WRITING_APP-eng: mkvmerge v53.0.0 ('Fool's Gold') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2021-03-15 04:54:47
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Metadata:
      BPS-eng         : 314047
      DURATION-eng    : 04:05:30.709000000
      NUMBER_OF_FRAMES-eng: 690502
      NUMBER_OF_BYTES-eng: 578268363
      _STATISTICS_WRITING_APP-eng: mkvmerge v53.0.0 ('Fool's Gold') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2021-03-15 04:54:47
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:2(eng): Subtitle: ass (default)
    Metadata:
      BPS-eng         : 132
      DURATION-eng    : 03:04:16.610000000
      NUMBER_OF_FRAMES-eng: 2525
      NUMBER_OF_BYTES-eng: 183731
      _STATISTICS_WRITING_APP-eng: mkvmerge v53.0.0 ('Fool's Gold') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2021-03-15 04:54:47
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:3(jpn): Subtitle: ass
    Metadata:
      BPS-eng         : 235
      DURATION-eng    : 03:04:33.060000000
      NUMBER_OF_FRAMES-eng: 3386
      NUMBER_OF_BYTES-eng: 325684
      _STATISTICS_WRITING_APP-eng: mkvmerge v53.0.0 ('Fool's Gold') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2021-03-15 04:54:47
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
    Stream #0:4(chi): Subtitle: ass
    Metadata:
      BPS-eng         : 131
      DURATION-eng    : 03:04:21.120000000
      NUMBER_OF_FRAMES-eng: 3048
      NUMBER_OF_BYTES-eng: 181298
      _STATISTICS_WRITING_APP-eng: mkvmerge v53.0.0 ('Fool's Gold') 64-bit
      _STATISTICS_WRITING_DATE_UTC-eng: 2021-03-15 04:54:47
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES

答案1

您的输出显示:

流#0:2(eng):字幕:ass(默认)

但是,mp4 不支持ass。您需要提取ass,将其转换为mp4支持的内容,然后将两者混合。ffmpeg -i <input.mkv> -vf subtitles=<input.mkv> <output.mp4>是一种方法。或者,我听说有一种名为手断

相关内容