Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > New and alternative a/v containers

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th January 2004, 14:14   #1  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
HowTo mux Subs into MP4 via MPEG-4 Systems

As i mentioned in my FAQ the MPEG-4 Standard expects any Text (including Subs) to be stored in BIFS format in MP4 atm

Now i know of two tools which are capable of converting SRT subs into BIFS format:
first dvd2mp4gui, with a nice newbie proof interface (but the author removed it from his webspace )

the second option is the very powerfull mp4box tool from gpac ("Gpac MPEG4 toolbox")
as its commandline and expecting a bt/xmt script as input this small guide may help you a bit with it:

1) download my small mp4sub script from sourceforge
2) place the script, mp4box and all needed media files in the same folder
3) open the script and search for "pixelWidth", "pixelHeight" and TextAppearance.position and adjust the values fitting your input as described in the script
4) adjust the names of your input files in the script
5) run the following commanline:
Code:
mp4box.exe -mp4 mp4sub_0.1.bt
6) thats enough to be able to play the output MP4 file with any good systems 2D capable player, like GPAC's Osmo4
EnvivioTV (a systems decoder usable in directshow) has some drawbacks, which means it needs some special treatment to make subs work, which is described below
if you play the MP4 file with a non-systems capable player (ie 3ivx) the subs will simply be ignored



Special Workaround for EnvivioTV

i saw that EnvivioTV doesnt seem to be able to handle a file with 2 BIFS tracks (Animationstream) correctly, as the ones created with the steps 1-6 (it also doesnt handle MP3 decoding), thats why we have to merge them into 1 to make it understandable for EnvivioTV, which works as follows

7) after running steps 1-6, rename the output .mp4 file you got to output.mp4 and run the following commanline:
Code:
mp4box.exe -bt output.mp4
this will create a new .bt script, named output.bt which we now have to merge with the old one, mp4sub_0.1.bt (which already has the updated paths, subtitle size/font aso set...)

8) open your first mp4sub_0.1.bt, which you worked on already, and change "DEF SubtitleText" to "DEF N1"

9) delete the following lines there too
Code:
    DEF MovieSubtitle AnimationStream {
      url [ "od:30" ]
    }
and
Code:
  ObjectDescriptor {	
    objectDescriptorID 30
    esDescr [
      ES_Descriptor {
	ES_ID 3
	muxInfo MuxInfo {
	  fileName "your_srt-subs_name.srt"		# only srt subs are supported in mp4box!
	  textNode SubtitleText 
	  fontNode SubtitleFont 
	}
      }
    ]
  }
10) open the new output.bt and copy all lines which look similar like this
Code:
RAP AT 200 IN 3 {
 REPLACE N1.string BY ["But I don't understand, " "Coelho Bastos."]
}

RAP AT 2870 IN 3 {
 REPLACE N1.string BY []
 REPLACE N2.style BY ""
}
and place them in the same order as they were in output.bt at the end of all lines in your first mp4sub_0.1.bt

11) change all lines in the following way that
Code:
RAP AT 2870 IN 3 {
 REPLACE N1.string BY ["But I don't understand, " "Coelho Bastos."]
 REPLACE N2.style BY ""
}
becomes
Code:
AT 2870 {
 REPLACE N1.string BY ["But I don't understand, Coelho Bastos."]
}
which means you have to
- delete all ' REPLACE N2.style BY "" ' lines,
- delete all ' RAP ' and
- delete all ' IN 3 '
- delete all ' " " ', which are placed in the middle of the subtitletext
this process can be made much easier and automated if you use the "search and change" option in m$ word

12) if your audio stream is not in AAC (ie MP3) you need to convert it to AAC! EnvivioTV isnt able to decode other audio formats than AAC
if you have to reencode the audio dont forget to adjust the name of your input audiofile in the script

13) after that run the following commandline again on the new created mp4sub_0.1.bt:
Code:
mp4box.exe -mp4 mp4sub_0.1.bt
now you have merged the two BIFS streams into one and will be able to play the BIFS subtitles also with EnvivioTV in every dshow based player (WMP9, BSPlayer, Media Player Classic) and also in Quicktime and Realplayer, but of course also with every other Systems 2D player, like Osmo4

13) enjoy


edit:
changed the title from "the spec compliant way" to "via MPEG-4 Systems", as the way ahead handles subs in mp4 is not not-spec-compliant

edit2: added a special guide, which makes BIFS subs working with EnvivioTV in quicktime, realplayer and directshow
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free

Last edited by bond; 23rd April 2004 at 09:06.
bond is offline   Reply With Quote
Old 30th January 2004, 23:29   #2  |  Link
Phobos
Registered User
 
Join Date: Jun 2002
Location: Guadalajara, Jalisco, México
Posts: 122
hey dude, new mp4box at rarewarez wont run with your script, it says parsing done and right after it i get a windows error something like "referenced memory cant be written" or stuff. so it wont do a thing, and im using the very same settings as the old one
Phobos is offline   Reply With Quote
Old 30th January 2004, 23:42   #3  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
no problem here
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 31st January 2004, 06:45   #4  |  Link
Phobos
Registered User
 
Join Date: Jun 2002
Location: Guadalajara, Jalisco, México
Posts: 122
now i tried out another movie but i got like a 1000 errors like this while importing avi:

"warning: invalid frame ts (CTS<DTS) - frame delay may be wrong"

anyway it now plays well on osmo (i still dont get any sound), but i couldnt see the subtitles this time.

And the "top left corner bug" on media player classic remains
Phobos is offline   Reply With Quote
Old 31st January 2004, 11:51   #5  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
hm this message has something to do with the new b-frame handling feature in mp4box

what codec, settings did you use to create the file?
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 31st January 2004, 17:10   #6  |  Link
Phobos
Registered User
 
Join Date: Jun 2002
Location: Guadalajara, Jalisco, México
Posts: 122
XVid 1.04 i used VHQ 4, chroma, no trellis, no packet bitstream, MPEG, adaptive quantization no qpel or gmc, motion search precision 6, no turbo and the lowest quant at 2
Phobos is offline   Reply With Quote
Old 1st February 2004, 20:04   #7  |  Link
JasonFly
Registered User
 
JasonFly's Avatar
 
Join Date: Apr 2002
Location: France
Posts: 180
I have a question
That seems to me that we can only mux txt subs into mp4 with the tools you adviced.
I assume that we cannot mux Vobsub subs into mp4, Am I right?

That seem to be a new vesion of the 3ivx splitter these days, can he decode mp4 subs or not?

Thanks
JasonFly is offline   Reply With Quote
Old 1st February 2004, 20:24   #8  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
well there are atm two ways to have subs in mp4
1) the one described here, which means storing the subs in bifs format (which would btw allow using all sorts of funky designs for the subs (ie "star wars subs" (c) shitowax ))

you can create such subs with any bifs encoding tool available (ie mp4box, mp4tool, xmtbatch)
note that only mp4box handles .srt input directly! with the other tools you would have to transform the subtitle text by hand (as no automatic conversion tools exist atm)

2) nero recode2 adds the subs directly in the vobsub format to mp4, also atm only the nero dshow filter support playing these
but note that 3ivx is also considering handling these subs
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 13th April 2004, 02:36   #9  |  Link
Snollygoster
SwiftAVS Developer
 
Join Date: Jan 2002
Location: Granite City
Posts: 198
After doing what you described with mp4box and the script I get the message parsing done and then cpu usage is 100% by mp4box and nothing happens for a long time. Is that normal? Where it should output the multiplexed mp4 file? If it was just multiplexing shouldn't the cpu usage be less than 100% (avimux, vdubmod or any other tool that just multiplexes uses the hard disk and cpu is around 30%)...
__________________
SwiftAVS AviSynth Script Generator
Snollygoster is offline   Reply With Quote
Old 13th April 2004, 09:15   #10  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
hm interesting... what cpu do you use?
also mp4box often rewrites the stream, which isnt displayed but needs some time, so its good to wait

also its important that you use the latest cvs as it includes some important fixes
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 18th April 2004, 16:27   #11  |  Link
gotaserena
String Theorist
 
Join Date: Mar 2003
Location: Na terra dos 10000 lagos.
Posts: 218
Hi Bond,

The subtitles are supposed to show as "BIFS" type of stream in MP4UI, aren't they?

If yes, I will have to figure out why Osmo4 is not showing them (as a matter of fact I'm still having trouble having it decoding AAC audio, but that's another problem.)

By the way, GPAC 0.1.3 is out. I hope someone has a good mind of posting some binaries soon. I can't get to compile them at home...
gotaserena is offline   Reply With Quote
Old 18th April 2004, 20:07   #12  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
Mpeg4 with subtitles in MP4 request, please.

Let me begin by saying I didn't know whether or not I should put this request in the 'New A/V Formats - Containers' section but here goes!

I'm after a short Mpeg4 video encode with subtitles all of which needs to be placed in a nice MP4 container. The subtitles must be encoded in the "official" way (ie: the xmt/bt text format) please!

Can somebody create and post an example please, so I can add to my 'test file' collection.

Many thanks
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 18th April 2004, 20:38   #13  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
Quote:
Originally posted by gotaserena
The subtitles are supposed to show as "BIFS" type of stream in MP4UI, aren't they?
exactly

Quote:
If yes, I will have to figure out why Osmo4 is not showing them (as a matter of fact I'm still having trouble having it decoding AAC audio, but that's another problem.)
can you upload a small sample, including the subs maybe?

and what problems do you have exactly with aac?
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 18th April 2004, 21:03   #14  |  Link
gotaserena
String Theorist
 
Join Date: Mar 2003
Location: Na terra dos 10000 lagos.
Posts: 218
Quote:
Originally posted by bond
can you upload a small sample, including the subs maybe?
I'll hunt around for a server... Theses things aren't easy to come by...

Quote:
and what problems do you have exactly with aac?
The usual "Stream setup failure: media codec not found" when I load the file. I use the 3ivx muxer, and did (re)install the 0.1.2 version which is supposed to have libfaad built-in.
gotaserena is offline   Reply With Quote
Old 18th April 2004, 21:11   #15  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
Quote:
Originally posted by gotaserena
The usual "Stream setup failure: media codec not found" when I load the file. I use the 3ivx muxer, and did (re)install the 0.1.2 version which is supposed to have libfaad built-in. [/B]
hm kilg0r3 reported the same here some days ago
try what is described there, it worked for kilg0r3

Quote:
Originally posted by SeeMoreDigital
I apologise, I totally missed this thread and posted the this request in another forum. Maybe you guys could help me out please?
i merged your thread with this one

hm if you need the sample to be widely compatible (ie with quicktime) and you only have few (always to be displayed) subs you maybe want to hardcode them onto the video stream anyways
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 18th April 2004, 21:45   #16  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
Quote:
Originally posted by bond
i merged your thread with this one

hm if you need the sample to be widely compatible (ie with quicktime) and you only have few (always to be displayed) subs you maybe want to hardcode them onto the video stream anyways
Thanks for doing that.

Actually, this time I'm not after a 'widely compatible' QuickTime solution! Nope, this time I'm interested to see if MP4 compliant subs will work with my Xcard and/or with software players.

Personally, I've never generated any type of encode with subtitles so I would not know where to start!

Cheers
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 18th April 2004, 21:56   #17  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
Quote:
Originally posted by SeeMoreDigital
Actually, this time I'm not after a 'widely compatible' QuickTime solution! Nope, this time I'm interested to see if MP4 compliant subs will work with my Xcard and/or with software players.
they will work with players capable of systems decoding
i doubt that your xcard handles this
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 18th April 2004, 22:25   #18  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
Quote:
Originally posted by bond
they will work with players capable of systems decoding
i doubt that your xcard handles this
It's worth a go though.

You never know.... I had to wait 2 years for an Mpeg4 codec that could provide anamorphic signalling, decent sounding AAC audio creation software and easy to use MP4 muxing tools before I knew the Xcard could handle anything remotely MP4-able

Cheers
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 20th April 2004, 21:12   #19  |  Link
gotaserena
String Theorist
 
Join Date: Mar 2003
Location: Na terra dos 10000 lagos.
Posts: 218
Hi,

I saved the stream from the file with mp4ui and opened it in a hex editor. The subtitle info is indeed there, at least the text is. Is there any other player that will display them?

I'll try and upload a sample later as soon as I figure out how to cut up srt files.
gotaserena is offline   Reply With Quote
Old 20th April 2004, 21:46   #20  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
Quote:
Originally posted by gotaserena
I saved the stream from the file with mp4ui and opened it in a hex editor. The subtitle info is indeed there, at least the text is. Is there any other player that will display them?
you mean you extracted the bifs stream with mp4ui?

hm if i remember it correctly mp4box places the sub stream as a seperate bifs stream in mp4 (so basically we have two bifs streams than)
now if gabests vsfilter could read out the bifs stream containing the subs-only it would be great
basically he only needs to read out the time and the text to display, the rest could be ignored
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:11.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.