Embed SRT Subtitles in MP4 as tx3g Using FFmpeg

This guide explains how to embed SubRip (SRT) subtitles into an MP4 video container as Apple-compatible timed text (tx3g) using the FFmpeg command-line tool. You will learn the exact command syntax to convert and mux subtitle streams, assign language metadata, and handle multiple subtitle tracks quickly without re-encoding your original video and audio files.

The Basic Command

To embed a single SRT subtitle file into an MP4 container as timed text (which FFmpeg refers to as mov_text), use the following command:

ffmpeg -i input.mp4 -i subtitle.srt -c copy -c:s mov_text output.mp4

Command Breakdown

  • -i input.mp4: Specifies the input video file.
  • -i subtitle.srt: Specifies the input SRT subtitle file.
  • -c copy: Instructs FFmpeg to stream copy the video and audio tracks. This process is instant and prevents any loss in quality because no re-encoding occurs.
  • -c:s mov_text: Specifies the subtitle encoder. In MP4 containers, mov_text writes the subtitles as MPEG-4 Part 17 timed text (the tx3g format), which is widely compatible with Apple devices, QuickTime, and HTML5 players.
  • output.mp4: The resulting video file containing the embedded subtitle track.

Adding Language Metadata

To ensure media players correctly identify the language of your subtitle track, you should add a language metadata tag. Use the -metadata:s:s:0 option followed by the 3-letter ISO 639-2 language code (e.g., eng for English, spa for Spanish, fra for French):

ffmpeg -i input.mp4 -i subtitle.srt -c copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4

Embedding Multiple Subtitle Tracks

If you need to embed multiple subtitle files for different languages into a single MP4 container, you must map the inputs and define the metadata for each stream:

ffmpeg -i input.mp4 -i english.srt -i spanish.srt \
-map 0 -map 1 -map 2 \
-c copy -c:s mov_text \
-metadata:s:s:0 language=eng \
-metadata:s:s:1 language=spa \
output.mp4
  • -map 0 -map 1 -map 2: Tells FFmpeg to include all streams from the first input (video/audio from input.mp4), the second input (English subtitles), and the third input (Spanish subtitles) in the final output file.
  • -metadata:s:s:0: Sets the metadata for the first subtitle stream (index 0) to English.
  • -metadata:s:s:1: Sets the metadata for the second subtitle stream (index 1) to Spanish.