使用 ffmpeg 将音频流添加到文件,保留现有流

使用 ffmpeg 将音频流添加到文件,保留现有流

新的音频流损坏并且某些部分无法播放。

ffmpeg -i "file1.mkv" -i "file2.dts" -map 0:v -map 0:a -map 1:a -map 0:s -c:v copy -c:a copy -c:s copy -metadata:s:a:1 language=eng "output.mkv"

ffmpeg version N-92738-g3a36b0c4b8 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181201
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 24.101 / 56. 24.101
  libavcodec     58. 42.104 / 58. 42.104
  libavformat    58. 24.101 / 58. 24.101
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 46.101 /  7. 46.101
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, matroska,webm, from 'file1.mkv':
  Metadata:
    title           : file
    encoder         : libebml v0.7.9 + libmatroska v0.8.1
    creation_time   : 2005-03-18T16:49:43.000000Z
  Duration: 01:31:01.44, start: 0.000000, bitrate: 9257 kb/s
    Chapter #0:0: start 0.000000, end 406.239000
    Metadata:
      title           : 00:00:00.000
    Chapter #0:1: start 406.239000, end 719.510000
    Metadata:
      title           : 00:06:46.239
    Chapter #0:2: start 719.510000, end 1090.256000
    Metadata:
      title           : 00:11:59.510
    Chapter #0:3: start 1090.256000, end 1283.324000
    Metadata:
      title           : 00:18:10.256
    Chapter #0:4: start 1283.324000, end 1567.733000
    Metadata:
      title           : 00:21:23.324
    Chapter #0:5: start 1567.733000, end 1862.778000
    Metadata:
      title           : 00:26:07.733
    Chapter #0:6: start 1862.778000, end 2023.563000
    Metadata:
      title           : 00:31:02.778
    Chapter #0:7: start 2023.563000, end 2579.202000
    Metadata:
      title           : 00:33:43.563
    Chapter #0:8: start 2579.202000, end 2868.866000
    Metadata:
      title           : 00:42:59.202
    Chapter #0:9: start 2868.866000, end 3195.275000
    Metadata:
      title           : 00:47:48.866
    Chapter #0:10: start 3195.275000, end 3646.768000
    Metadata:
      title           : 00:53:15.275
    Chapter #0:11: start 3646.768000, end 4035.615000
    Metadata:
      title           : 01:00:46.768
    Chapter #0:12: start 4035.615000, end 4381.794000
    Metadata:
      title           : 01:07:15.615
    Chapter #0:13: start 4381.794000, end 4639.093000
    Metadata:
      title           : 01:13:01.794
    Chapter #0:14: start 4639.093000, end 4790.119000
    Metadata:
      title           : 01:17:19.093
    Chapter #0:15: start 4790.119000, end 5461.440000
    Metadata:
      title           : 01:19:50.119
    Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x818, SAR 1:1 DAR 960:409, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc
    Stream #0:1(rus): Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
    Stream #0:2(rus): Subtitle: subrip
    Stream #0:3(vie): Subtitle: subrip
    Stream #0:4(eng): Subtitle: subrip
    Stream #0:5(cze): Subtitle: subrip
    Stream #0:6(fin): Subtitle: subrip
    Stream #0:7(ger): Subtitle: subrip
    Stream #0:8(hun): Subtitle: subrip
    Stream #0:9(pol): Subtitle: subrip
    Stream #0:10(por): Subtitle: subrip
    Stream #0:11(rum): Subtitle: subrip
    Stream #0:12(spa): Subtitle: subrip
    Stream #0:13(swe): Subtitle: subrip
[dts @ 000002006791bc40] Estimating duration from bitrate, this may be inaccurate
Input #1, dts, from 'file2.dts':
  Duration: 01:29:25.46, start: 0.000000, bitrate: 1535 kb/s
    Stream #1:0: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s
File 'output.mkv' already exists. Overwrite ? [y/N] y
Output #0, matroska, to 'output.mkv':
  Metadata:
    title           : file
    encoder         : Lavf58.24.101
    Chapter #0:0: start 0.000000, end 406.239000
    Metadata:
      title           : 00:00:00.000
    Chapter #0:1: start 406.239000, end 719.510000
    Metadata:
      title           : 00:06:46.239
    Chapter #0:2: start 719.510000, end 1090.256000
    Metadata:
      title           : 00:11:59.510
    Chapter #0:3: start 1090.256000, end 1283.324000
    Metadata:
      title           : 00:18:10.256
    Chapter #0:4: start 1283.324000, end 1567.733000
    Metadata:
      title           : 00:21:23.324
    Chapter #0:5: start 1567.733000, end 1862.778000
    Metadata:
      title           : 00:26:07.733
    Chapter #0:6: start 1862.778000, end 2023.563000
    Metadata:
      title           : 00:31:02.778
    Chapter #0:7: start 2023.563000, end 2579.202000
    Metadata:
      title           : 00:33:43.563
    Chapter #0:8: start 2579.202000, end 2868.866000
    Metadata:
      title           : 00:42:59.202
    Chapter #0:9: start 2868.866000, end 3195.275000
    Metadata:
      title           : 00:47:48.866
    Chapter #0:10: start 3195.275000, end 3646.768000
    Metadata:
      title           : 00:53:15.275
    Chapter #0:11: start 3646.768000, end 4035.615000
    Metadata:
      title           : 01:00:46.768
    Chapter #0:12: start 4035.615000, end 4381.794000
    Metadata:
      title           : 01:07:15.615
    Chapter #0:13: start 4381.794000, end 4639.093000
    Metadata:
      title           : 01:13:01.794
    Chapter #0:14: start 4639.093000, end 4790.119000
    Metadata:
      title           : 01:17:19.093
    Chapter #0:15: start 4790.119000, end 5461.440000
    Metadata:
      title           : 01:19:50.119
    Stream #0:0(eng): Video: h264 (High) (H264 / 0x34363248), yuv420p(progressive), 1920x818 [SAR 1:1 DAR 960:409], q=2-31, 23.98 fps, 23.98 tbr, 1k tbn, 1k tbc
    Stream #0:1(rus): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
    Stream #0:2(eng): Audio: dts (DTS) ([1] [0][0] / 0x2001), 48000 Hz, 5.1(side), fltp, 1536 kb/s
    Stream #0:3(rus): Subtitle: subrip
    Stream #0:4(vie): Subtitle: subrip
    Stream #0:5(eng): Subtitle: subrip
    Stream #0:6(cze): Subtitle: subrip
    Stream #0:7(fin): Subtitle: subrip
    Stream #0:8(ger): Subtitle: subrip
    Stream #0:9(hun): Subtitle: subrip
    Stream #0:10(pol): Subtitle: subrip
    Stream #0:11(por): Subtitle: subrip
    Stream #0:12(rum): Subtitle: subrip
    Stream #0:13(spa): Subtitle: subrip
    Stream #0:14(swe): Subtitle: subrip
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
  Stream #1:0 -> #0:2 (copy)
  Stream #0:2 -> #0:3 (copy)
  Stream #0:3 -> #0:4 (copy)
  Stream #0:4 -> #0:5 (copy)
  Stream #0:5 -> #0:6 (copy)
  Stream #0:6 -> #0:7 (copy)
  Stream #0:7 -> #0:8 (copy)
  Stream #0:8 -> #0:9 (copy)
  Stream #0:9 -> #0:10 (copy)
  Stream #0:10 -> #0:11 (copy)
  Stream #0:11 -> #0:12 (copy)
  Stream #0:12 -> #0:13 (copy)
  Stream #0:13 -> #0:14 (copy)
Press [q] to stop, [?] for help
[matroska @ 000002006788d4c0] Starting new cluster due to timestamp
[matroska @ 000002006788d4c0] Starting new cluster due to timestampe=9826.4kbits/s speed= 164x
[matroska @ 000002006788d4c0] Starting new cluster due to timestampe=10103.2kbits/s speed= 107x
[matroska @ 000002006788d4c0] Starting new cluster due to timestampe=10288.0kbits/s speed=92.2x
    Last message repeated 1 times
[matroska @ 000002006788d4c0] Starting new cluster due to timestampe=10338.8kbits/s speed=88.4x
    Last message repeated 4 times
[matroska @ 000002006788d4c0] Starting new cluster due to timestampe=10530.2kbits/s speed=84.6x
    Last message repeated 3 times
[matroska @ 000002006788d4c0] Starting new cluster due to timestampe=10771.6kbits/s speed=81.2x
    Last message repeated 2 times
[matroska @ 000002006788d4c0] Starting new cluster due to timestampe=10766.3kbits/s speed=74.6x
[matroska @ 000002006788d4c0] Starting new cluster due to timestampe=10695.5kbits/s speed=74.9x
[matroska @ 000002006788d4c0] Starting new cluster due to timestampe=10697.1kbits/s speed=61.4x
    Last message repeated 1 times
[matroska @ 000002006788d4c0] Starting new cluster due to timestampte=10761.4kbits/s speed=60.7x
    Last message repeated 4 times
[matroska @ 000002006788d4c0] Starting new cluster due to timestampte=10751.0kbits/s speed=60.5x
[matroska @ 000002006788d4c0] Starting new cluster due to timestampte=10663.0kbits/s speed=  61x
frame=130943 fps=1452 q=-1.0 Lsize= 7182536kB time=01:31:01.45 bitrate=10773.6kbits/s speed=60.6x
video:5871250kB audio:1304696kB subtitle:404kB other streams:0kB global headers:0kB muxing overhead: 0.086194%

答案1

那么使用 mkvmerge 怎么样?我相信它可能会解决问题。尝试以下命令行:

对于 AVI 文件作为输入:(如果需要,只需更改 your-file-without-dts-audio.avi 扩展名)

mkvmerge -o yourfinalresult.mkv your-file-without-dts-audio.avi yourdtsaudio.dts

或者...对于 MKV 文件作为输入:

mkvmerge -o yourfinalresult.mkv your-file-without-dts-audio.mkv yourdtsaudio.dts

尝试上述命令并告诉我它是否有效。

相关内容