Tool to add subtitles to mp4s

Random chit-chat and anything that doesn't belong elsewhere
entropic
Posts: 51
Joined: Wed Apr 11, 2007 8:38 am

Tool to add subtitles to mp4s

Postby entropic » Mon Apr 21, 2008 6:33 pm

As a side product of my srt releated work on handbrake i wrote a small macos cli-tool that adds subtitle tracks to existing mp4 files.
In case you want to give it a try:
http://muxo.entropicgarden.com/Muxo_v0.1.zip

Its in a really early stage - so don't be suprised if it destroys any files :D
Right now it only reads srt files - and can't handle any errors. Make sure that you are using a valid srt file or the result will be crap...
Run it without arguments to see how it is used.

I've lots of plans to extend this tool - eventually add a GUI.

Feedback is welcome....

User avatar
s55
HandBrake Team
Posts: 8224
Joined: Sun Dec 24, 2006 1:05 pm

Re: Tool to add subtitles to mp4s

Postby s55 » Mon Apr 21, 2008 7:19 pm

Don't suppose you'd be willing to share the source?

I was thinking I might compile on cygwin for windows users, then create a very quick/simple c# gui to interface with it.

entropic
Posts: 51
Joined: Wed Apr 11, 2007 8:38 am

Re: Tool to add subtitles to mp4s

Postby entropic » Mon Apr 21, 2008 7:40 pm

So additional infos:
For now it fails if you try to add subs to a file that has already been tagged - so only fresh handbrake encodes for now...

Even worse - it seems that MetaX is stripping my subtitle tracks out :(

Don't suppose you'd be willing to share the source?


Sure! Eventually i want a public svn repo for it...but right now I spend the little time i have available rather on actually implementing something...
My longterm goal is to create a full mp4 editor - to add/remove all kinds of tracks and metadata to files. All in an ipod/itunes/atv complatible way. Lets see... :)

http://muxo.entropicgarden.com/Muxo_v0.1a_src.zip
It's still pretty messy tho :mrgreen:

entropic
Posts: 51
Joined: Wed Apr 11, 2007 8:38 am

Re: Tool to add subtitles to mp4s

Postby entropic » Mon Apr 21, 2008 8:54 pm

Build 2
- now even with with tagged files :D


http://muxo.entropicgarden.com/Muxo_build_2.zip

kyc
Posts: 5
Joined: Mon Mar 03, 2008 8:58 am

Re: Tool to add subtitles to mp4s

Postby kyc » Tue Apr 22, 2008 7:27 am

Thanks for this. I was following all your threads on soft subtitles but I think it certainly makes more sense to add the subs after encoding so that we can make sure it syncs up. I can finally start encoding my foreign language movies now.

Just a couple of notes. It will fail to open the file if it has an AC3 track. Also the subs and the black bar are not centered on anamorphic encodes. The width is set to the actual video resolution and so it aligns left on widescreen anamorphic video. Fortunately, the iPhone does not read that information and it shows up nicely centered even on TV out.

entropic
Posts: 51
Joined: Wed Apr 11, 2007 8:38 am

Re: Tool to add subtitles to mp4s

Postby entropic » Tue Apr 22, 2008 1:30 pm

Exactly the kind of feedback i've been hoping for.
I'll try to fix the these issues later today.

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: Tool to add subtitles to mp4s

Postby dynaflash » Tue Apr 22, 2008 5:37 pm

Okay entropic, exactly *why* did you decide not to put this right in HandBrake ?? ;)

entropic
Posts: 51
Joined: Wed Apr 11, 2007 8:38 am

Re: Tool to add subtitles to mp4s

Postby entropic » Tue Apr 22, 2008 9:41 pm

Version 0.2
- now with GUI
- support for files with anamorphic video
- support for movies with ac3 track

http://muxo.entropicgarden.com/Muxo_0.2.zip


Okay entropic, exactly *why* did you decide not to put this right in HandBrake ??


Still ask myself the same question :D

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: Tool to add subtitles to mp4s

Postby dynaflash » Wed Apr 23, 2008 12:01 pm

entropic wrote:
Okay entropic, exactly *why* did you decide not to put this right in HandBrake ??


Still ask myself the same question :D


If your still willing, I think it would be a great addition to HB. Otherwise kudos on Muxo, very nice. :) Thanks.

entropic
Posts: 51
Joined: Wed Apr 11, 2007 8:38 am

Re: Tool to add subtitles to mp4s

Postby entropic » Wed Apr 23, 2008 6:32 pm

Version 0.3

What's new
- Added auto update
- Added more error checks
- Improved subtitle language selection

Known Issues
- Multiple subtitle tracks won't work in iPhone/iPod touch

Download here: http://muxo.entropicgarden.com/muxo.zip

kyc
Posts: 5
Joined: Mon Mar 03, 2008 8:58 am

Re: Tool to add subtitles to mp4s

Postby kyc » Thu Apr 24, 2008 7:59 pm

Thanks for continuing to update it. It works perfectly with everything I've throw at it so far.

The only flaws I've encountered (italic tags and the maximum of 2 rows of text), I assume are caused by Quicktime player's shoddy subtitle support because they show up perfectly fine on the iPhone. I'm still debating on whether I want to keep the tags.

Edit: Looks like I spoke a little too early. I finally had time to sit down a watch an entire movie with subtitles added using Muxo. The subtitles stopped showing up half way through the movie. I looked at all my other movies that I added subtitles to and it seemed to be a problem with all of them. The subtitles doesn't always go out at the same point but it's usually after the one hour mark. Looking at the movie properties in Quicktime, it looks like all the subtitle tracks are shorter than movie length. I checked the srt files at the point where the subtitle track stops but they all seem to be.

entropic
Posts: 51
Joined: Wed Apr 11, 2007 8:38 am

Re: Tool to add subtitles to mp4s

Postby entropic » Thu Apr 24, 2008 10:03 pm

kyc wrote:Thanks for continuing to update it. It works perfectly with everything I've throw at it so far.

The only flaws I've encountered (italic tags and the maximum of 2 rows of text), I assume are caused by Quicktime player's shoddy subtitle support because they show up perfectly fine on the iPhone. I'm still debating on whether I want to keep the tags.

Edit: Looks like I spoke a little too early. I finally had time to sit down a watch an entire movie with subtitles added using Muxo. The subtitles stopped showing up half way through the movie. I looked at all my other movies that I added subtitles to and it seemed to be a problem with all of them. The subtitles doesn't always go out at the same point but it's usually after the one hour mark. Looking at the movie properties in Quicktime, it looks like all the subtitle tracks are shorter than movie length. I checked the srt files at the point where the subtitle track stops but they all seem to be.


:shock: Doh! Just noticed the same thing... can't belive i've missed this all the time
Will be fixed in v0.3.2 (eg. probably tomorrow)

Edit
Was quicker then i expected... got it fixed.
Just grab the latest version directly from the appcast http://muxo.entropicgarden.com/appcast.xml or just use auto update in Muxo.

Edit 2
kyc wrote:...The only flaws I've encountered (italic tags and the maximum of 2 rows of text), I assume are caused by Quicktime player's shoddy subtitle support because they show up perfectly fine on the iPhone. I'm still debating on whether I want to keep the tags....

I'm not conviced yet that the subtitle support of quicktime is still so crappy compared to the iphone. Maybe I'm just missing something here.
As soon as I figure this out Ill add a feature to Muxo that lets you correct this issue in existing mp4s with subtitles. (+ remove and change language of subtitle tracks...)

rhester
Veteran User
Posts: 2888
Joined: Tue Apr 18, 2006 10:24 pm

Re: Tool to add subtitles to mp4s

Postby rhester » Fri Apr 25, 2008 3:06 pm

I humbly beg of you that, whatever direction this takes, please always make sure a multiplatform, command-line-only version of Muxo exists. There is a huge market for this outside of HandBrake, particularly with past-ripped content. While I'd very much like to see something like this integrated into HB, there will always be a need for a stand-alone tool with this feature set.

Now if only CCExtractor could get the timings right... (van, you ever get my personal message on this? ;)

Rodney

nightstrm
Veteran User
Posts: 1887
Joined: Fri Mar 23, 2007 5:43 am

Re: Tool to add subtitles to mp4s

Postby nightstrm » Fri Apr 25, 2008 3:17 pm

Wait a second... this tool gives us soft subtitle support in iTunes/Quicktime-compatible mp4s? :shock:

Now I need to learn how to rip subtitles from DVDs...

dynaflash
Veteran User
Posts: 3820
Joined: Thu Nov 02, 2006 8:19 pm

Re: Tool to add subtitles to mp4s

Postby dynaflash » Fri Apr 25, 2008 6:02 pm

Methinks entropic has a winner here ...

refulgentis
Bright Spark User
Posts: 342
Joined: Mon Apr 14, 2008 5:08 am

Re: Tool to add subtitles to mp4s

Postby refulgentis » Sun Apr 27, 2008 9:48 pm

i have a file it just plain isn't working with...I've tried using muxo, then tried doing it the old 'manual' way. the ttxt file looks fine, all the track atoms look fine in dumpster. mplayer is recognizing the track and displaying subtitles, ffmpeg recognizes the subtitle track, but neither quicktime nor vlc is even acknowledging the MP4 has an additional track beyond the audio and video.


i'll try using another sub source next, but I'm fairly sure its being saved as a proper SRT, I had jumbler (subtitle tool for os x) save it as sub, then I reopened it and reexported it as an SRT.

not sure what's going on here :/

the only other thing I can think that's odd that I'm doing is using ffmpeg to encode audio, mencoder to encode video, and then muxing it with mp4box, but that shouldn't be a problem? i've tried remuxing the raw AAC and H.264 and subtitles all in one fell swoop with mp4box too.

nightstrm
Veteran User
Posts: 1887
Joined: Fri Mar 23, 2007 5:43 am

Re: Tool to add subtitles to mp4s

Postby nightstrm » Sun Apr 27, 2008 10:00 pm

So, how would one generate a compatible subttle file from a DVD in OSX? I want to play around with this, but just realized I've never tried to create a subtitle file in OSX (and it's been awhile in Windows as well).

TedJ
Veteran User
Posts: 5388
Joined: Wed Feb 20, 2008 11:25 pm

Re: Tool to add subtitles to mp4s

Postby TedJ » Mon Apr 28, 2008 2:25 am

Perhaps D-Subtitler will be suitable, although I still prefer using Subrip under Windows.

refulgentis
Bright Spark User
Posts: 342
Joined: Mon Apr 14, 2008 5:08 am

Re: Tool to add subtitles to mp4s

Postby refulgentis » Mon Apr 28, 2008 5:10 am

tried different video files, different srt sources...same odd results. I was fine until I started muxing with mp4box (oooold version, 0.4.3dev), next step for me is trying to get it recompiled on OS X, which seems to be a chore right now...

refulgentis
Bright Spark User
Posts: 342
Joined: Mon Apr 14, 2008 5:08 am

Re: Tool to add subtitles to mp4s

Postby refulgentis » Mon Apr 28, 2008 7:09 am

found a binary version of 0.4.4 MP4Box, Quicktime and VLC still don't want to pick up that an additional track beyond video even exists

to recap:
i'm transcoding 720p MKVs to raw H.264 using MEncoder (so no audio, just the raw H.264 video, I've also done a standard XviD dvd rip in an AVI)
making that into an MP4 using mp4box -add file.264#video container.mp4
then using Muxo

this won't work, so I tried
mp4box -ttxt file.srt
then
mp4box -add file.ttxt -add file.264#video container.mp4
and then used dumpster to change the media handler to sbtl
still won't work. :/

pleae let me know what could help you further, if you would like example files I can probably upload something to rapidshare containing a small sample file, the raw H.264, and the muxed MP4 that quicktime can't recognize the subtitles in

entropic
Posts: 51
Joined: Wed Apr 11, 2007 8:38 am

Re: Tool to add subtitles to mp4s

Postby entropic » Mon Apr 28, 2008 7:20 am

mp4box -add file.ttxt -add file.264#video container.mp4


You sure you changed the file extension over to .m4v? Quicktime wont recognize the track otherwise.
If this is not the issue, please upload a sample and i'll figure out why it doesn't work with muxo.

refulgentis
Bright Spark User
Posts: 342
Joined: Mon Apr 14, 2008 5:08 am

Re: Tool to add subtitles to mp4s

Postby refulgentis » Mon Apr 28, 2008 7:57 am

entropic wrote:
mp4box -add file.ttxt -add file.264#video container.mp4


You sure you changed the file extension over to .m4v? Quicktime wont recognize the track otherwise.
If this is not the issue, please upload a sample and i'll figure out why it doesn't work with muxo.
oh god.

i just spent literally 12 hours (after I got home from work at 4 PM EST until now at 3:56 AM EST) hacking around with trying to compile mp4box 4.5, different muxing techniques, different x264 encoding techniques, different shell scripts etc etc etc
and all it was, was that I didn't change to m4v :roll: :lol:

thanks SO much for all your work on this by the way, as long as I'm posting

EDIT: well, quicktime is recognizing it, but they're not actually displaying in either itunes or quicktime. under visual settings in the movie properties in quicktime, it says the subtitle track is "0x60" pixels, which I'm assuming is the problem, or is this not a problem and something else is wrong?
EDIT2: yep, changing the width from 0 and then changing the offset from -60 fixed it

entropic
Posts: 51
Joined: Wed Apr 11, 2007 8:38 am

Re: Tool to add subtitles to mp4s

Postby entropic » Mon Apr 28, 2008 9:00 am

yep, changing the width from 0 and then changing the offset from -60 fixed it


Is this happening when you add the subtitle track with muxo, or if you do it with mp4box?
I know for a fact that mp4box is not handling everything correctly (in the sense of 'not the apple way') when adding subtitles.
If muxo does it, please give me a small sample file so I can try to fix it.

refulgentis
Bright Spark User
Posts: 342
Joined: Mon Apr 14, 2008 5:08 am

Re: Tool to add subtitles to mp4s

Postby refulgentis » Mon Apr 28, 2008 9:28 am

entropic wrote:
yep, changing the width from 0 and then changing the offset from -60 fixed it


Is this happening when you add the subtitle track with muxo, or if you do it with mp4box?
I know for a fact that mp4box is not handling everything correctly (in the sense of 'not the apple way') when adding subtitles.
If muxo does it, please give me a small sample file so I can try to fix it.

muxo, I had a 'clean' (mp4box'd raw AAC + raw H264) file, then muxo'd subs in...I'll cut down the size a little bit (its 720 MB, maybe I'll make a 1 minute sample?) and upload it to rapidshare later, and then edit this post to include the link

EDIT:
~ 1 min clip of the movie: http://rapidshare.de/files/39252654/muxotest.m4v.html
srt file I'm using: http://rapidshare.de/files/39252657/lost.srt.html

dlorenzo
Posts: 3
Joined: Thu Apr 17, 2008 4:12 am

Re: Tool to add subtitles to mp4s

Postby dlorenzo » Mon Apr 28, 2008 12:55 pm

Everything looks great on Quicktime but now how do I "turn on" subtitles on AppleTV, I've already switched to on the show closed captions option in the settings menu, but still nothing.

Anyone has a clue?


Return to “Tiki Bar”