Embed SRT Subtitles into MP4 via FFmpeg on Linux

Embedding SRT subtitles directly into an MP4 file on Linux allows you to combine your video and text tracks into a single, highly compatible file. This process can be done either by soft-coding the subtitles (adding them as a togglable track that can be turned on or off) or hard-coding them (burning them permanently into the video frames). Using the powerful command-line tool FFmpeg, you can achieve both results quickly with just a single line of terminal command, depending on whether you want to preserve the original video quality or ensure universal playback across all media players.

Soft-Coding Subtitles (Togglable Track)

Soft-coding is the preferred method if you want to keep the process fast and avoid re-encoding the video. It adds the SRT file as a separate data stream inside the MP4 container, allowing viewers to turn the subtitles on or off in players like VLC or MPV. Because it copies the original video and audio streams without altering them, this execution takes only a few seconds.

To soft-code your subtitles, open your Linux terminal and run the following command:

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

In this command, -i input.mp4 and -i subtitles.srt specify your source files. The -c copy flag tells FFmpeg to stream-copy the video and audio without re-encoding them, which preserves the exact original quality. Crucially, -c:s mov_text converts the SRT subtitle format into mov_text, which is the standard, officially supported subtitle format for the MP4 container.

Hard-Coding Subtitles (Burned-In Text)

Hard-coding is necessary when you need the subtitles to appear on absolutely any device or platform, including older hardware or social media sites that do not support subtitle tracks. This method permanently “burns” the text into the video pixels. Because FFmpeg has to modify the actual image frames, the entire video must be re-encoded, which will take longer and use more CPU power.

To hard-code your subtitles, use the video filter flag in your terminal:

ffmpeg -i input.mp4 -vf "subtitles=subtitles.srt" -c:a copy output.mp4

Here, the -vf "subtitles=subtitles.srt" argument invokes FFmpeg’s video filter graph to overlay the text directly onto the video stream. Because the video is being modified, FFmpeg automatically re-encodes it using the default H.264 codec. The -c:a copy flag ensures that the audio stream is still copied directly without re-encoding, saving processing time and maintaining original audio fidelity.