FFmpeg Map Video and Subtitles from Different Files

This article provides a quick and practical guide on how to use FFmpeg to combine a video track from one file with a subtitle track from another file. You will learn the exact command-line syntax required to map these specific streams and save the combined result into a new container without the need for time-consuming re-encoding.

To map streams from different files in FFmpeg, you use the -map option. FFmpeg indexes input files starting from 0. Therefore, the first input file is 0, and the second input file is 1.

Command to Map Video, Audio, and External Subtitles

In most cases, you will want to keep the video and audio from your primary media file and add the subtitles from a secondary file. Use the following command:

ffmpeg -i video_source.mp4 -i subtitle_source.srt -map 0:v -map 0:a -map 1:s -c copy output.mkv

Command Breakdown

Command to Map Only Video and Subtitles (No Audio)

If you want to extract only the video track from the first file (excluding its audio) and merge it with the subtitles from the second file, use this command:

ffmpeg -i video_source.mp4 -i subtitle_source.srt -map 0:v -map 1:s -c copy output.mkv

By omitting the -map 0:a parameter, FFmpeg will ignore the audio track entirely during the merging process.