You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用FFmpeg批量提取MKV文件中的印尼SRT字幕?

批量提取MKV文件中的印尼语字幕

Got it, let's tackle this batch subtitle extraction problem. Since you already know how to pull Indonesian subtitles from a single file with FFmpeg, scaling this to your 17 files in the dots folder is straightforward with a bash loop. Here are two reliable approaches:

方法1:基于语言代码的批量提取(推荐)

This method is more robust because it targets subtitles by their language code (ind for Indonesian) instead of a fixed stream index—stream numbers can vary between different MKV files, so this avoids errors if some files have different stream layouts.

  1. First, navigate to your dots folder:

    cd /home/jaac/torrents/rtorrent/dots
    
  2. Run this bash loop to process all MKV files:

    for file in *.mkv; do
      ffmpeg -i "$file" -map 0:s:m:language:ind "${file%.mkv}_indo.srt" -y
    done
    

Let's break down the key parts:

  • "$file": Quotes ensure the command handles filenames with spaces or special characters correctly.
  • -map 0:s:m:language:ind: Tells FFmpeg to pick the subtitle stream (s) from the input file (0) that matches (m) the Indonesian language code ind.
  • ${file%.mkv}_indo.srt: Creates a subtitle filename that matches the original MKV (e.g., Title.NF.WEB-DL.DDP2.0.x264-Ao.mkv becomes Title.NF.WEB-DL.DDP2.0.x264-Ao_indo.srt).
  • -y: Automatically overwrites existing .srt files if they exist. Remove this flag if you want FFmpeg to prompt you before overwriting.

方法2:固定流索引的批量提取(仅当所有文件的印尼语字幕都是第7个流)

If you're absolutely certain every MKV in your folder has the Indonesian subtitle at stream index 0:7, you can reuse your original command in a loop:

cd /home/jaac/torrents/rtorrent/dots
for file in *.mkv; do
  ffmpeg -i "$file" -map 0:7 "${file%.mkv}_indo.srt" -y
done

额外小贴士:验证字幕流信息

Before running the batch command, you can double-check the subtitle streams in any file to confirm the language or index. Use ffprobe (included with FFmpeg) for this:

ffprobe -v error -select_streams s -show_entries stream=index:stream_tags=language -of csv=p=0 "YourFile.mkv"

This will output something like:

5,eng
7,ind

Which confirms stream 7 is Indonesian (ind), so your original single-file command works for that specific file.

内容的提问来源于stack exchange,提问作者jaac

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 16:48:13