Extract subtitles from mp4 file

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.

Identify which track contains the subtitles:

$ ffmpeg -i video.mp4
    Stream #0:1(und): Audio: [...]
    Stream #0:2(eng): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
      handler_name    : SubtitleHandler
    Stream #0:3: Video:  [...]

Then, replacing -codec:s:X.Y with the actual stream channel found in the output above:

ffmpeg -i video.mp4 -vn -an -codec:s:0.2 srt video.srt

With newer versions of ffmpeg the parameters are simplified to -codec:s:Y, so with the output from above it is:

ffmpeg -i video.mp4 -vn -an -codec:s:2 srt video.srt