subtitle

How To Add Subtitle In A Video File Using FFmpeg

There are times that we have to add a subtitle into a movie just to make sure we understand the spoken dialogue these Korean films and Koreanovelas or any other foreign films that don’t have any subtitles.

What is a subtitle

Subtitles are text derived from either a transcript or screenplay of the dialog or commentary in films, television programs, video games, and the like, usually displayed at the bottom of the screen, but can also be at the top of the screen if there is already text at the bottom of the screen. They can either be a form of written translation of a dialog in a foreign language, or a written rendering of the dialog in the same language, with or without added information to help viewers who are deaf or hard of hearing to follow the dialog, or people who cannot understand the spoken dialogue or who have accent recognition problems.

What you need
  • Laptop or computer
  • FFmpeg
  • Video file
  • SRT file (SubRip subtitle)
Download FFmpeg

We’ll have to download FFmpeg first and place it in a folder anywhere. I recommend downloading the static build of FFmpeg and place it in your C: drive root directory, for example, C:ffmpeg. Also, I suggest that you add it to your Path Environment Variable if you’re on Windows so you can use FFmpeg in any directory.

Next, we need to look for an SRT file for the particular movie. Just go to www.opensubtitles.org, which is an open-source repository for any movie or TV subtitles. Download and extract it somewhere like in your desktop for easy access.

Then, locate your movie or the video file that you want to add a subtitle with. You may also copy it to your desktop for quicker access.

Open the command prompt by searching it on your start menu. Let’s assume that you’ve added FFMpeg already in your Path Environment Variable from the previous section.

Enter the command below in your command prompt:
ffmpeg -i path-to-the-video-file -i path-to-the-subtitle-file -vcodec copy -acodec copy -scodec copy -map 0:0 -map 0:1 -map 1:0 -y new-name-for-your-video-file.mp4

The process will insert first the movie file and then the subtitle file. -vcodec copy will just copy the codec from the original video file to your new video file. -acodec copy will also copy the audio codec from the original file to the new file. -scodec is for subtitle codec. While -map is for the streams. For example, if you have two audio streams in the first input file, these streams are identified by “0:0” and “0:1”. You can use -map to select which streams to place in an output file. You may refer to the FFmpeg documentation for the parameters here.

Once the process is finished, a new video file will be saved on the same directory as where you opened the command prompt. That’s it! If you face any further issues, please feel free to comment below.

Facebook Comments