Convert video with subtitles to MP4 for iPhone/iPad (preliminary notes)

By now, we know of a few requirements for viewing video on iOS (iPhone/iPad et al.). The video codec should be H.264 or another “standard” MPEG codec, and the audio should be AAC. AC3, as far as I know, is not supported. That’s all fine and dandy, but subtitles have been one of the trickiest things to get working on iOS.

The video should be in an MP4 container, and it’s relatively easy to remux from anything to MP4 in one step using ffmpeg, avidemux, mencoder, and so on. Any unsupported audio should be transcoded into AAC into the process, but remuxing itself should only take a few seconds.

Subtitles need to be extracted with whatever tool you have at your disposal. Mkvextract is the way to go with MKV, but SSA/ASS subs are not supported (if that wasn’t assumed already). There is a script ass2srt.pl that will handle the conversion for you, and iOS can understand ttxt subtitles in addition to srt. MP4Box can convert srt to ttxt and vice-versa, and maybe a couple other formats.

The tricky part is getting all the bits right. Use MP4Box to add the subtitles to the mp4 with something like MP4Box -add mysubs.srt:hdlr=sbtl:lang=eng myvideo.mp4. However, if MP4Box says it can’t understand the URL even though you’ve typed it correctly, it could be that your MP4Box version is too old to be able to set the “hdlr” field to “sbtl”. If so, run it with just -add mysubs.srt:lang=eng and then use sed to replace “text” with “sbtl”.

Finally, rename your video file to use the “.m4v” extension instead of “.mp4” (ugh, really?).

If all goes well, you should see a new subtitle selector pop up next to the play controls when you play the video full-screen on your iDevice.

5 Responses to “Convert video with subtitles to MP4 for iPhone/iPad (preliminary notes)”

  1. toni writes:

    I know this is an old post, but this is still relevant stuff. What you could cover here is the multiple subtitles solution with MP4Box, which makes this even a bit trickier.

  2. SolidPires writes:

    This method works. However, if i try and stream the video through iTunes to my iphone the subtitle appear only in iTunes, not the iPhone. Any thoughs?

  3. toni writes:

    I used this set of arguments for maximum combatibility:
    MP4Box -add video.mp4 -add video.srt:hdlr=sbtl:lang=fin:group=2:layout=640x50x0x-1 -add video-ee.srt:hdlr=sbtl:lang=est:group=2:layout=640x50x0x-1 -new result\video.mp4

  4. toni writes:

    I have to mention to the above comment that size of the video was 640 by 360 pixels so I used the layout property to make sure the alignment of the subtitles yilded a desired result.

  5. bestautumnn writes:

    Have you tried Avdshare?
    It will show you a step by step guide on how to find and download the right subtitles for your MP4 videos as well as add subtitles to MP4. In fact, this guide also applies to add subtitles to AVI, MKV, WTV, WMV, VOB, MPG, MOV, DV, FLV, WebM, OGV, and etc.

Leave a Reply