How to Add SRT to Video Without Encoding Using FFmpeg
This article explains how to use FFmpeg to insert localized SRT subtitle tracks into a video container like MP4 or MKV without re-encoding the video or audio streams. By utilizing stream copying, you can preserve the original video quality and complete the process in just a few seconds. Below, you will find step-by-step instructions for basic remuxing, adding language metadata for localization, handling MP4 containers, and merging multiple subtitle tracks into a single file.
The Basic Command (MKV Container)
The Matroska (MKV) container natively supports SubRip (SRT)
subtitles. To merge an external SRT file with a video without
re-encoding, use the -c copy flag. This tells FFmpeg to
copy the video, audio, and subtitle streams directly without modifying
them.
ffmpeg -i input.mp4 -i subtitle.srt -c copy output.mkv-i input.mp4: Specifies the input video file.-i subtitle.srt: Specifies the input subtitle file.-c copy: Instructs FFmpeg to stream-copy all tracks (video, audio, and subtitles) without re-encoding.
Adding Localized Language Metadata
To ensure media players recognize the language of the subtitle track,
you must assign a three-letter ISO 639-2 language code (such as
eng for English, spa for Spanish, or
fra for French) using metadata tags.
ffmpeg -i input.mp4 -i subtitle_es.srt -c copy -metadata:s:s:0 language=spa output.mkv-metadata:s:s:0 language=spa: Targets the first subtitle stream (s:s:0) and sets its language metadata to Spanish (spa).
Adding Multiple Localized Subtitle Tracks
You can add multiple localized subtitle tracks to a single video
container. To do this, you must explicitly map each input file to the
output file using the -map option, then define the metadata
for each subtitle stream.
ffmpeg -i input.mp4 -i sub_en.srt -i sub_es.srt \
-map 0 -map 1 -map 2 \
-c copy \
-metadata:s:s:0 language=eng -metadata:s:s:0 title="English" \
-metadata:s:s:1 language=spa -metadata:s:s:1 title="EspaƱol" \
output.mkv-map 0: Maps all streams from the first input (the video).-map 1: Maps the second input (the English subtitle) as the first subtitle stream (s:s:0).-map 2: Maps the third input (the Spanish subtitle) as the second subtitle stream (s:s:1).title="...": Sets a user-friendly name for the subtitle track selection menu in media players.
Adding Subtitles to an MP4 Container
Unlike MKV, the MP4 container does not natively support raw SRT text
format. To add subtitles to an MP4 container without re-encoding the
video or audio, you must convert the SRT subtitle stream to the
MP4-compatible Timed Text format (mov_text).
ffmpeg -i input.mp4 -i subtitle.srt -c:v copy -c:a copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4-c:v copy: Stream-copies the video without encoding.-c:a copy: Stream-copies the audio without encoding.-c:s mov_text: Converts the subtitle stream to Timed Text format compatible with MP4.