Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

brc76

macrumors newbie
Original poster
Oct 19, 2008
9
0
Hi all,
The ATV now supports CC (soft subs) - in a beta version I know - but still I'm interested in experimenting with it.

Whenever hearing about making CC I hear Muxo or Compressor which both are non-windows compatible afaik.

Anyone has a solution for embedding CC in my h264 when using a Win OS only?
I'm not buying a mac quite yet so that doesnt count for a valid solution :)

Any pointers are greatly appreciated as I have been unable to find anything on google that remotely solves my problem.

Kind regards
brc
 

PluueeR

macrumors newbie
Oct 1, 2008
8
0
You can use MP4Box to import a ttxt file into your mp4 file:

MP4Box -add [ttxtfilepath]:lang=[yourlangcode] [path_to_a_valid_mp4_file]

You can convert a .srt file to .ttxt using:

MP4Box -ttxt [srtfilepath])

Afterwards you need to edit a your .mp4v (on Mac use Dumpster, I don't know about a Windows equivalant). Set moov..mdia.hdl.subType to sbtl. Now you have your subtitles on your Apple TV. However the top is cut off and just one line is displayed.
 

brc76

macrumors newbie
Original poster
Oct 19, 2008
9
0
Thanx for your reply - I was closer than I thought.

Here is what I've done so far
1) Converted to h264 from mkv
2) Extracted subs from original mkv with MKVExtractGUI that's based on mkvtoolnix (http://www.videohelp.com/tools/MKVExtractGUI)
3) Converted to ttxt via yamb that's based on mp4box (http://yamb.unite-video.com/)
4) added the ttxt stream to the container by using yamb
5) ensured that the extension was m4v and not mp4 (you can just rename to get the proper effect)
6) Used QT Atom Viewer (http://tsviatko.jongov.com/index_prj_quicktimeviewer.htm) to determine my point of entry which you stated and is mentioned here http://hendrik.kaju.pri.ee/2008/08/24/quicktime-subtitles-revealed/. The Atom viewer was veeery slow but it got it gave me a hex offset.
7) Used ultraedit (http://www.ultraedit.com/downloads/ultraedit_download.html) to find the offset and change it to the correct value (text->sbtl). For future passes I think i will skip step 6 and just seach in the binary code for "text".
8) Tada... captions that can be switch on/off via QT (havnt tried it on my ATV yet though.

However...
- The language is listed as "unknown". How can one change that?
- The subtitle is located top left instead of bottom center. How to change that?
 

brc76

macrumors newbie
Original poster
Oct 19, 2008
9
0
Did some more digging:

- The undefined language track was my own fault - I didnt explicitly select the language for the stream. When selecting this it worked like a charm.
However, when I try to insert 2 text streams by doing the same steps (listed above) I am only able to control 1 of the added streams. The second stream is not listed as a possible selection i QT but is still shown (as subs) all the time and hence I have 2 text streams displayed when I select the first one to be enabled in QT. I assumed that I was able to add more that one text stream.
Is this a known error or am I doing smth wrong?

- I still have position problems with the ttxt. I have played with the settings according to http://gpac.sourceforge.net/doc_ttxt.php but still no cigar. Is this a known error as well or have I forgotten smth obvious?

- I have tried to embed srt's instead of ttxt's but these show even bigger problems (very large text). Funny thing is that if I don't do the "text"->"sbtl" step the text looks acceptable and in the right position but with no QT enable/disable support. Which of srt or ttxt is the better choice when the final goal is ATV (in a future ATV update that supports CC correctly of course) - religion or ...?

Any inputs are very welcome - especially if the errors above are known errors and hence would be pointless to hunt down.

Kind regards
brc
 

brc76

macrumors newbie
Original poster
Oct 19, 2008
9
0
I've done some more testing

I've actually just tried to play the m4v on the ATV and here subs has the correct position when using ttxt's. It would seem that it is QT that is flawed in this equation. I can - as expected - switch the text stream on and off via the option menu on the ATV when playing the m4v.

Initially the subtitle looks as it should - no cut-off but just one line. I dont think it is a problem for me just yet because my test subject (The.Orphanage.2007.720p.BluRay.DTS.x264-ESiR.mkv) doesnt seem to have 2 liners any where (?). I must say I find it perfect until now.

Only thing left (just for the sake of completeness) is to obtain more text streams in same m4v (different languages) but my efforts has been in vain so far.

As always input is greatly appreciated.

Kind regards
brc
 

FastJack42

macrumors newbie
Nov 14, 2008
3
0
- The subtitle is located top left instead of bottom center. How to change that?

You can alter the position of the subtitles in Quicktime. Select the track in Quicktime and then go to visual settings. There you can edit the offset of the subtitles. Though after saving the movie in Quicktime again you'll get a mov instead m4v file. (I still don't quite get the difference between those two)

There is a second way however. Edit it directly in Dumpster. The offset is stored in moov > trak > tkhd > matrix. In my example I set an offset of 158x500 for my movie. This resulted in the following values in the last line of the matrix: 0.0158, 0.0500, 0.01. You get the picture :)
 

FastJack42

macrumors newbie
Nov 14, 2008
3
0
Actually looking at it again. You don't even need to set the position of the subtitles in Dumpster. The ttxt file contains the position too. Just look at the following code from my file:
Code:
<TextStreamHeader width="400" height="60" layer="0" translation_x="158" translation_y="500">
The translation parameters are already there. No need for Dumpster.

Now I wish there was a way to get rid of Dumpster altogether. Maybe dump the track as xml with mp4box, change its handler subtype to "sbtl" and then import those settings back into the movie file?
 

brc76

macrumors newbie
Original poster
Oct 19, 2008
9
0
Thank you for your replies. I have - until now - concluded that things work fine on ATV but not so good in QT. Until those two handle text streams similar I wont do anything further.

However, I'm still investigating on how to embed more that 1 text stream in the m4v container but havnt been able to do so. Any pointers on this issues would be very welcome... and please remember that everything has to be done on a Win OS platform.

Kind regards
brc
 

FastJack42

macrumors newbie
Nov 14, 2008
3
0
Basically there is no limit for the number of subtitle tracks. You can use MP4Box to add a bunch of subtitles. Just indicate the language of the subtitle with the three letter country code (use MP4Box -languages to get a list of the supported country codes). Then change the handler subtype of the tracks from text to sbtl.
Since you most probably want to see only one subtitle track at the same time you need to put them all in the same alternate group. You'll find the "alternateGroup" in each tracks header (moov/trak/tkhd). Each alternate group is just a unique value inside the movie. Since alternate group 1 is usually taken by alternate audio tracks you can take alternate group 2. Just put the same value into all subtitle tracks alternate groups.
That's it. This should work on Windows as well as on Mac OS X. The only difference is how you edit the QT atoms. On Mac OS X you can do that with Dumpster (that's what I'm using). On Windows you can do that with QT Atom Viewer and a hex editor.
I only tried playing that movie on my Mac in Quicktime since I don't have an Apple TV. It works fine on the Mac. I suppose that later firmware upgrades for the Apple TV will fix the subtitle problem you described earlier in this thread.
 

brc76

macrumors newbie
Original poster
Oct 19, 2008
9
0
Better late that never - but I finally got around to test your suggestion.

You are indeed right! I changed the alternate group from 0 to 2 for both sbtl tracks and everything worked as it should! Thank You.

I desperately need dumpster for windows though (is such a project perhaps in the making somewhere?) the Atom viewer is not what I need and I found myself counting offset bytes based on the Movie Atoms documentation - way too error prone...

/brc
 

eduo

macrumors member
May 27, 2002
53
0
Mexico
Actually looking at it again. You don't even need to set the position of the subtitles in Dumpster. The ttxt file contains the position too. Just look at the following code from my file:
Code:
<TextStreamHeader width="400" height="60" layer="0" translation_x="158" translation_y="500">
The translation parameters are already there. No need for Dumpster.

Now I wish there was a way to get rid of Dumpster altogether. Maybe dump the track as xml with mp4box, change its handler subtype to "sbtl" and then import those settings back into the movie file?

Did you ever encounter a way to avoid Dumpster altogether? It's useless for automating processes, really.

Muxo is no help as its development has stopped and Handbrake has refused to accept the patches to include this in the program.

I assume either MP4Box or a modified AtomicParsley should be able to set this bit correctly (and I'm half thinking of traversing the sourcecode for mp4box to search for the ttxt atom and change it to sbtl and recompile, just to see how it goes).

Have you found anything on this front?
 

brc76

macrumors newbie
Original poster
Oct 19, 2008
9
0
This was idd to be my next step. I havnt got around to reversing the code but it shouldt be too hard as the principle - as you state - is fairly simple.

This will be a long term project for me so dont expect anything too soon :) I will post any findings here none-the-less, I hopy equally minded will do the same.

/brc
 

eduo

macrumors member
May 27, 2002
53
0
Mexico
Well. I have tried.

I have traversed as best as I can the MP4Box code. I can't find which instance of "text" is the one that actually sets the atom's fourcc name.

Since using sed from the command line to replace all instances of "text" (or "0000text0000" if you want to play it safe) works to set all text tracks so they're recognized by apple programs and devices (except for the non-touch ipods) and pre-setting in the ttxt the correct width (full width of video) and height (20% of height of video) ends up giving perfect subtitles, changing that atom's fourcc from "text" to "sbtl" should be enough to create the track properly to begin with (instead of having to run the whole video through a search & replace routine).

I've gone and asked in the sf forums for MP4Box for help on where to locate this fourcc to change it in source and compile a personal version (as I only want to see the videos in Apple devices. I've also separately made a request for an "Apple Format" switch in the app itself. Seeing the activity of these forums I suspect none of these two will be answered.
 

Justinb81

macrumors newbie
Feb 23, 2009
2
0
The Netherlands
I am having some problems with using your sed method.
I am using the line:
sed s/0000text0000/0000sbtl0000/ <movie.m4v >movie_sub.m4v

But the resulting fille is unreadable by quicktime or dumpster.

I have also been trying to automate the encoding process, the sbtl part and the automatic positioning of the sub in the .ttxt is still giving me problems.
 

eduo

macrumors member
May 27, 2002
53
0
Mexico
I am having some problems with using your sed method.
I am using the line:
sed s/0000text0000/0000sbtl0000/ <movie.m4v >movie_sub.m4v

But the resulting fille is unreadable by quicktime or dumpster.

I have also been trying to automate the encoding process, the sbtl part and the automatic positioning of the sub in the .ttxt is still giving me problems.

I have been using sed for a while now, like this:

Code:
cat tmp_"$NEWFILE" |sed -e's/text/sbtl/g' > "$NEWFILE"

(part of a larger script I use, right after AtomicParsley and mp4box adding the sub.

I was documenting this yesterday here: http://forum.entropicgarden.com/viewtopic.php?f=2&t=14967&p=15367#p15367

When I got a PM elsewhere pointing me to this: http://forum.doom9.org/showthread.php?t=145192

And then today I got another, to an open source muxo alternative: Subler.

http://forum.handbrake.fr/viewtopic.php?f=14&t=9197

So I'm a happy camper now.
 

Justinb81

macrumors newbie
Feb 23, 2009
2
0
The Netherlands
You Sir, are my hero!

I will pass on the subler way, because it uses a GUI.
But I will try to use the C code on my windows box.
The reason I want to use a Windows machine to encode is because my fastest Mac OS machine is a PowerMac G4 450dp and the Windows machine is a Core2Duo.
If there is an alternative to Vroksub (A subtitle downloader for opensubtitles.org) I want to switch the rest of the handling to my Mac machines.

This is what I have so far on my Windows Server (my Mac os knowledge isn't enough to come with a equivalent:)

------------------------
Convert.bat

::Set variables
set MP4BOX=d:\conversion\tools\MP4Box.exe
set VROKSUB=d:\conversion\tools\VrokSub.exe
set SED=d:\conversion\tools\sed\bin\sed.exe
set HANDBRAKE=d:\conversion\tools\HandBrakeCLI.exe
set WINRAR=C:\Progra~1\WinRAR\winrar.exe
set ATOMIC=d:\conversion\tools\AtomicParsley.exe



::Lock the conversion
IF EXIST d:\CONVERSION\lock.txt GOTO END
copy d:\CONVERSION\lockfile\lock.txt d:\CONVERSION\lock.txt



::Copy all Downloaded files and unpack the rars
::Move files to D:\downloaded\
D:\
MOVE D:\bittorrent\done\*.* D:\downloaded\
cd D:\downloaded\

::Unrar Downloaded files - var %%r and delete the rars
for /f %%r IN ('dir /b /s *.rar') do call start /wait cmd /c "%WINRAR% X -o+ %%r"
DEL /q /S *.r??
D:
cd D:\downloaded\

::Delete the sample movies
del /s /q *sample*.*



::Sort movies by type
::Move The TV Shows into the conversion directory per show
for /f %%a IN ('dir /b /s *bones*.avi') do call start /wait cmd /c "move %%a D:\video\avi\tvshows\bones\unsubbed\"

::Move AVI files into the conversion directory
for /f %%b IN ('dir /b /s *.avi') do call start /wait cmd /c "move %%b D:\video\avi\unsubbed\"

::Move MKV files into the conversion directory
for /f %%c IN ('dir /b /s *.mkv') do call start /wait cmd /c "move %%c D:\video\mkv\unsubbed\"


::Find subtitles
::Find subtitles for the TV Shows
start /wait "%VROKSUB% "D:\video\avi\tvshows\bones\unsubbed" nl /move="D:\video\avi\tvshows\bones\subbed""

::Find subtitles for the avi's
start /wait "%VROKSUB% "D:\video\avi\unsubbed" nl /move="D:\video\avi\subbed""

::Find subtitles for the mkv's
start /wait "%VROKSUB% "D:\video\mkv\unsubbed" nl /move="D:\video\mkv\subbed""

::rename nl named files to usable files - var %%d
cd D:\video\
for /f %%d IN ('dir /b /s *.avi') do call start /wait cmd /c "rename %%~nd.nl.srt %%~nd.srt"



::Convert Srt to TTXT - var %%e %%f %%g
::Bones
cd D:\video\avi\tvshows\bones\subbed\
for /f %%e IN ('dir /b /s *.srt') do call start /wait cmd /c ""%MP4BOX%" -ttxt "%%e""
move *.ttxt e:\convert\tvshows\subbing\
DEL /q *.srt

::AVI
cd D:\video\avi\subbed\
for /f %%f IN ('dir /b /s *.srt') do call start /wait cmd /c ""%MP4BOX%" -ttxt "%%f""
move *.ttxt e:\convert\avi\subbing\
DEL /q *.srt

::MKV
cd D:\video\mkv\subbed\
for /f %%g IN ('dir /b /s *.srt') do call start /wait cmd /c ""%MP4BOX%" -ttxt "%%g""
move *.ttxt e:\convert\mkv\subbing\
DEL /q *.srt



::Conversion LOOP for Subtitled Movie files

:CONVERT
IF EXIST D:\video\avi\tvshows\bones\subbed\*bones*.avi GOTO BONES
IF EXIST D:\video\avi\subbed\*.avi GOTO AVI
IF EXIST D:\video\avi\subbed\*.avi GOTO MKV
IF EXIST D:\video\DVD\*.* GOTO DVD
DEL d:\CONVERSION\lock.txt
GOTO END






::Convert the TV Show Bones, Add iTunes Episode information and finish it

:BONES
::Handbrake converts SUBBED AVI to M4V without chapters - var %%a
d:
cd D:\video\avi\tvshows\bones\subbed\
for /f %%a IN ('dir /b *.avi') do call start /wait cmd /c ""%HANDBRAKE%" -i "%%a" -t 1 -c 1 -o "e:\convert\tvshows\subbing\%%~na.m4v" -f m4v -4 -X 960 -P -e x264 -q 0.59 -2 -T -a 1,1 -E faac,ac3 -B 160 -R 48,0 -6 dpl2,dpl2 -D 1,1 -x level=30:cabac=0:ref=3:mixed-refs=1:bframes=6:weightb=1:direct=auto:no-fast-pskip=1:me=umh:subq=7:analyse=all -v"
DEL /q *.*

::mux ttext into m4v - var %%h
e:
cd e:\convert\tvshows\subbing\
for /f %%h IN ('dir /b *.m4v') do call start /wait cmd /c ""%MP4BOX%" -add "%%~nh.ttxt":lang=nld "%%h""

::Rename TV Show to usable format
e:
CD e:\convert\tvshows\finished\
::Rename file for further processing - Bones.S04E14.HDTV.XviD-LOL.m4v to Bones-04-14.m4v
for /f "tokens=1,2,3,4* delims=.SE" %%a IN ('dir /b *.m4v') do rename %%a.S%%bE%%c.%%d*.m4v %%a-%%b-%%c.m4v
::Goto working directory
d:
CD e:\convert\tvshows\finished\
::Set iTunes Atoms
for /f "tokens=1,2,3 delims=-." %%a IN ('dir /b *.m4v') do %ATOMIC% %%a-%%b-%%c.m4v --stik "TV Show" --genre "TV Shows" --TVShowName "%%a" --TVSeasonNum "%%b" --TVEpisodeNum "%%c" --TVEpisode "%%b%%c" --artwork d:\conversion\art\bones\bones.jpg"
move *.m4v e:\convert\tvshows\finished\
DEL /q e:\convert\tvshows\subbing\*.*

GOTO CONVERT



:AVI
::Handbrake converts SUBBED AVI to M4V without chapters - var %%a
d:
cd D:\video\avi\subbed\
for /f %%a IN ('dir /b *.avi') do call start /wait cmd /c ""%HANDBRAKE%" -i "%%a" -t 1 -c 1 -o "e:\convert\avi\subbing\%%~na.m4v" -f m4v -4 -X 960 -P -e x264 -q 0.59 -2 -T -a 1,1 -E faac,ac3 -B 160 -R 48,0 -6 dpl2,dpl2 -D 1,1 -x level=30:cabac=0:ref=3:mixed-refs=1:bframes=6:weightb=1:direct=auto:no-fast-pskip=1:me=umh:subq=7:analyse=all -v"
DEL /q *.avi

::mux ttext into m4v - var %%i
e:
cd e:\convert\avi\subbing\
for /f %%i IN ('dir /b *.m4v') do call start /wait cmd /c ""%MP4BOX%" -add "%%~ni.ttxt":lang=nld "%%i""
move *.m4v e:\convert\avi\finished\
DEL /q e:\convert\avi\subbing\*.*

GOTO CONVERT



:MKV
d:
::Handbrake converts subbed MKV to M4V without chapters - var %%a
cd D:\video\mkv\subbed\
for /f %%a IN ('dir /b *.mkv') do call start /wait cmd /c ""%HANDBRAKE%" -i "%%a" -t 1 -c 1 -o "e:\convert\avi\subbing\%%~na.m4v" -f m4v -4 -X 960 -P -e x264 -q 0.59 -2 -T -a 1 -E faac -B 160 -R 48 -6 dpl2 -D 1 -x level=30:cabac=0:ref=3:mixed-refs=1:bframes=6:weightb=1:direct=auto:no-fast-pskip=1:me=umh:subq=7:analyse=all -v"
DEL /q *.mkv

::mux ttext into m4v - var %%j
e:
cd e:\convert\mkv\subbing\
for /f %%j IN ('dir /b *.m4v') do call start /wait cmd /c ""%MP4BOX%" -add "%%~nj.ttxt":lang=nld "%%j""
move *.m4v e:\convert\mkv\finished\
DEL /q e:\convert\mkv\subbing\*.*

GOTO CONVERT



:DVD
rem call start /wait d:\CONVERSION\BATCHFILES\DVD.BAT
GOTO CONVERT

:END
 

brc76

macrumors newbie
Original poster
Oct 19, 2008
9
0
Thx for your replies - seems as if we are at the end of the road for now.

I have validated your findings and can now sum up :
- It is my experience that the new MP4box release writes sbtl instead of text so you dont have to do this step anymore
- It is my experience that you are required to change alternate group if you have more that one language track.

The executive summary on the original problem "how to make CC on a win OS?" will hence be:

  1. Produce target .m4v (via HB f.ex.)
  2. Isolate language track(s) in the .ttxt format (convert if necessary possibly via MP4Box)
  3. Add language track(s) to target via MP4Box (MP4Box.exe -add <mylang_laguagetrack>.ttxt:lang=<mylang> target.m4v). Run as many times as you have tracks
  4. If > 1 language track be sure to change alternate group to 2 which must be done for all language tracks - this is done manually (hex edit) until the tools can do it (or can they already?). If this is not done you can't toggle the different languges independently. How this is done is explained in the posts above

I'm looking forward to when HB will support it all - according to the roadmap it will be available in the next public release.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.