Set Forced Track Flag on MKV Subtitle Using FFmpeg

This article provides a straightforward, step-by-step guide on how to use FFmpeg to set the “forced” track flag on a specific subtitle stream inside an Matroska (MKV) container. By modifying the stream’s disposition metadata without re-encoding the video or audio, you can ensure that compatible media players automatically enable forced subtitles, such as those used for foreign language translation scenes.

Step 1: Identify the Subtitle Stream Index

Before applying the flag, you must identify the index of the subtitle stream you wish to modify. You can do this by running ffprobe on your input file:

ffprobe input.mkv

Look through the output for the subtitle streams. They are typically labeled as Subtitle: subrip, Subtitle: ass, or Subtitle: hdmv_pgs_subtitle.

FFmpeg indexes streams of a specific type starting at 0. For example: * s:0 refers to the first subtitle stream. * s:1 refers to the second subtitle stream.

Step 2: Run the FFmpeg Command

To set the forced flag, use the -disposition option. The following command copies all video, audio, and subtitle streams without re-encoding (-c copy) and marks the first subtitle stream (s:0) as forced:

ffmpeg -i input.mkv -c copy -disposition:s:0 forced output.mkv

Setting Both Default and Forced Flags

Often, players require a subtitle stream to be marked as both “default” and “forced” to play automatically. You can combine these flags using a plus sign (+):

ffmpeg -i input.mkv -c copy -disposition:s:0 default+forced output.mkv

Removing the Forced Flag from Other Streams

If your MKV file has multiple subtitle streams and you want to ensure only one is marked as forced, you should explicitly strip the flag from the other streams.

For example, to make the second subtitle stream (s:1) forced and ensure the first subtitle stream (s:0) is not forced, use:

ffmpeg -i input.mkv -c copy -disposition:s:1 forced -disposition:s:0 0 output.mkv

Setting the disposition value to 0 clears all flags for that specific stream.