How to Set Hearing Impaired Flag in MKV with FFmpeg
This article provides a quick and direct guide on how to use FFmpeg to set the hearing-impaired flag on audio or subtitle streams inside an MKV (Matroska) container. By using FFmpeg’s disposition metadata mapping, you can flag these streams for media players without needing to re-encode the video or audio tracks.
Setting the Flag on Subtitles
To flag a subtitle stream as hearing-impaired (often used for SDH -
Subtitles for the Deaf and Hard-of-hearing), use the
-disposition option targeting the subtitle stream
index.
The following command sets the hearing-impaired flag on the first
subtitle stream (s:0) while copying all video, audio, and
subtitle data without re-encoding:
ffmpeg -i input.mkv -c copy -disposition:s:0 hearing_impaired output.mkvSetting the Flag on Audio
If you have a dedicated audio description stream or an audio track designed for the hearing-impaired, you can flag it in a similar way.
The following command sets the hearing-impaired flag on the first
audio stream (a:0):
ffmpeg -i input.mkv -c copy -disposition:a:0 hearing_impaired output.mkvSetting the Flag on Multiple Streams Simultaneously
If you want to apply the hearing-impaired flag to both the first audio stream and the first subtitle stream at the same time, combine the disposition arguments into a single command:
ffmpeg -i input.mkv -c copy -disposition:a:0 hearing_impaired -disposition:s:0 hearing_impaired output.mkvTargeting Specific Streams
If your MKV file contains multiple audio or subtitle tracks, you can target specific ones by changing the index number:
-disposition:s:1 hearing_impairedtargets the second subtitle track.-disposition:a:2 hearing_impairedtargets the third audio track.
Because the -c copy flag is used, this process is
extremely fast and preserves the exact quality of your original
file.