How to Set Subtitle Language in FFmpeg

This guide explains how to set or change the language metadata code (such as ‘spa’ for Spanish or ‘jpn’ for Japanese) for a subtitle stream using FFmpeg. You will learn the precise command-line arguments needed to target specific subtitle streams and apply the correct ISO 639 language codes without re-encoding your video.

The Basic Syntax

To set the language of a subtitle stream, you use the -metadata:s:s option. The syntax is broken down as follows:

Scenario 1: Changing Language on an Existing File

If you have a video file that already contains a subtitle stream, and you want to change its language metadata to Spanish (spa) without re-encoding the video or audio, use the following command:

ffmpeg -i input.mkv -map 0 -c copy -metadata:s:s:0 language=spa output.mkv

Command Breakdown:

Scenario 2: Adding an External Subtitle and Setting its Language

If you are merging an external subtitle file (like an .srt or .vtt file) into a video and want to set its language to Japanese (jpn), use this command:

ffmpeg -i input.mp4 -i subtitle.srt -map 0 -map 1 -c copy -metadata:s:s:0 language=jpn output.mkv

Command Breakdown:

Handling Multiple Subtitle Streams

If your file has multiple subtitle streams and you want to label them differently, you can target each stream by its index:

ffmpeg -i input.mkv -map 0 -c copy -metadata:s:s:0 language=eng -metadata:s:s:1 language=fra output.mkv

In this example, the first subtitle stream (s:s:0) is set to English (eng), and the second subtitle stream (s:s:1) is set to French (fra).