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

FFmpeg是否支持生成多轨WebVTT格式的HLS字幕?

FFmpeg是否支持多轨WebVTT格式的HLS字幕?

Absolutely, FFmpeg does support generating HLS streams with multiple WebVTT subtitle tracks. The problem you're encountering (only one track being recognized) is almost always tied to missing or misconfigured command parameters, not a limitation of FFmpeg itself.

Correct Command Example for Multiple Subtitle Tracks

Let’s say you have a video file input.mp4, plus two WebVTT subtitle files: subs_en.vtt (English) and subs_zh.vtt (Chinese). Here’s a properly structured FFmpeg command to package them into an HLS stream with both subtitle tracks:

ffmpeg -i input.mp4 -i subs_en.vtt -i subs_zh.vtt \
  -c:v copy -c:a copy \
  -c:s webvtt \
  -map 0:v -map 0:a \
  -map 1:s -metadata:s:s:0 language=eng -metadata:s:s:0 group-id="subs" -metadata:s:s:0 name="English" \
  -map 2:s -metadata:s:s:1 language=zho -metadata:s:s:1 group-id="subs" -metadata:s:s:1 name="Chinese" \
  -hls_segment_type mpegts -hls_flags independent_segments \
  -master_pl_name master.m3u8 output_%v.m3u8

Key Parameters to Note

  • -map directives: These explicitly tell FFmpeg which streams to include. Each subtitle track gets its own -map entry to ensure it’s not omitted from the output.
  • Metadata tags:
    • language=XXX sets the ISO 639-2 language code (e.g., eng for English, zho for Chinese) — this is critical for players to identify and label subtitle tracks correctly.
    • group-id="subs" groups all subtitle tracks under a single ID, so players recognize them as interchangeable options for the same content.
    • name="XXX" adds a human-readable label for the subtitle track (shows up in player menus).
  • -hls_flags independent_segments: Ensures each HLS segment is self-contained, which is required for smooth subtitle track switching.
  • -master_pl_name master.m3u8: Generates a master playlist that lists all available streams (video, audio, subtitles). Players use this master file to detect and access multiple subtitle tracks.

Troubleshooting Tips if Only One Track is Recognized

  1. Check the master playlist: Open master.m3u8 in a text editor — you should see separate #EXT-X-MEDIA entries for each subtitle track, like:
    #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",LANGUAGE="eng",URI="output_subs_0.m3u8"
    #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Chinese",LANGUAGE="zho",URI="output_subs_1.m3u8"
    
    If one is missing, double-check your -map and metadata parameters.
  2. Validate subtitle files: Make sure your input WebVTT files follow the standard format (no syntax errors, proper timestamps, etc.). You can test them by loading them directly in a browser to confirm they work.
  3. Player compatibility: Some older or simpler HLS players might not support multiple subtitle tracks, but most modern players (like Safari, Chrome, or VLC) do. Test with a widely supported player to rule out player-side issues.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 06:25:25