Skip to main content

Extract subtitles from mp4 files using MP4Box

Jose CerrejonLess than 1 minuteAppleLinuxAppleLinux

Extract subtitles from mp4 files using MP4Box

subtitles
subtitles

Quick tip to extract subtitles from mp4 with the tool MP4Box available on OSX/Linux

. In OSX, we use brewopen in new window to install MP4Box.

When installed, type the next to get info from the video file:

MP4Box -info input.mp4
...
Track # 4 Info - TrackID 4 - TimeScale 1000
Media Duration 02:23:33.789 - Indicated Duration 02:23:33.789
Media Info: Language "Spanish; Castilian (spa)" - Type "sbtl:tx3g" - 204 samples
Unknown Text Stream
 Size 1280 x 80 - Translation X=0 Y=455 - Layer -1
	RFC6381 Codec Parameters: tx3g
Alternate Group ID 2
	All samples are sync
...

Now we look for the Track we want to extract (with the type sbtl:tx3g). If there are several, look for "samples" which are the lines that has the subtitle file. If the sample number are short, you are generally forced subtitles with important content as names, other languages ... Now we pass the ID of the track to the next instruction:

MP4Box -srt <Track_ID> Input.mp4 
MP4Box -srt 4 input.mp4 # Example