Extract MP4 Subtitles to WebVTT Using FFmpeg

This article provides a quick, step-by-step guide on how to extract subtitle tracks from an MP4 video file and convert them into the WebVTT (.vtt) format using FFmpeg. You will learn how to identify the correct subtitle stream inside your MP4 container and run the precise command-line instructions needed to output a clean WebVTT file for web compatibility.

Step 1: Identify the Subtitle Track

Before extracting, you need to find which stream index corresponds to the subtitles inside your MP4 file. Run the following command in your terminal:

ffmpeg -i input.mp4

Look through the output for lines labeled Subtitle. They usually look like this:

Stream #0:2(eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)

In this example, the subtitle is the third stream (0:2), and it is the first subtitle track (which can be referenced as 0:s:0).

Step 2: Extract and Convert to WebVTT

Once you know the stream index, use the -map option to select the subtitle stream and define a .vtt output file. FFmpeg will automatically handle the conversion from the MP4 subtitle format (usually mov_text) to WebVTT.

Run the following command to extract the first subtitle track:

ffmpeg -i input.mp4 -map 0:s:0 output.vtt

Command Breakdown: