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. Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se |
|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 | Link |
|
Registered User
Join Date: May 2003
Posts: 109
|
How to add own, subtitles (resp. pure text) into existing MP4 video?
Assume I have an existing well-encoded MP4 video WITHOUT subtitles.
Now I want to add the text "foobar testtext" with fontsize=18 and fontfamily Verdana into video beginning at 1min23sec and ending at 3min44sec centralized 30 pixels above lower border. How can I most easily achieve this? I possible/necessary the text could be put fix encoded into video and not only as traditional subtitle. Last edited by mike23; 9th December 2018 at 13:51. |
|
|
|
|
|
#2 | Link |
|
Registered User
Join Date: Oct 2011
Posts: 275
|
Hello,
there is a few problems when it comes to your specific needs: Most players will ignore the fonts and size defined and will use the ones set in the players subtitles options. MP4 container using a tool like MP4Box to remux is theoretically able to achieve what you need using the subtitles .ttxt format, but i don't have any player able to respect the .ttxt formats so i don't know if it will even work correctly... anyways : https://gpac.wp.imt.fr/mp4box/ttxt-f...documentation/ The .ttxt file content will look something like this for a video of 1920x1080px resolution: Code:
<?xml version="1.0" encoding="UTF-8" ?> <!-- GPAC 3GPP Text Stream --> <TextStream version="1.1"> <TextStreamHeader width="1920" height="1080" layer="0" translation_x="0" translation_y="0"> <TextSampleDescription horizontalJustification="center" verticalJustification="bottom" backColor="0 0 0 0" verticalText="no" fillTextRegion="no" continuousKaraoke="no" scroll="None"> <FontTable> <FontTableEntry fontName="verdana" fontID="1"/> </FontTable> <TextBox top="0" left="0" bottom="1050" right="1920"/> <Style styles="Normal" fontID="1" fontSize="18" color="ff ff ff ff"/> </TextSampleDescription> </TextStreamHeader> <TextSample sampleTime="00:00:00.000" sampleDescriptionIndex="1" xml:space="preserve"></TextSample> <TextSample sampleTime="00:01:23.000" sampleDescriptionIndex="1" xml:space="preserve">foobar testtext</TextSample> <TextSample sampleTime="00:03:44.000" sampleDescriptionIndex="1" xml:space="preserve"></TextSample> </TextStream> The MP4Box command will be : Code:
MP4Box.exe -add "H:\inputFile.mp4#video" -add "H:\inputFile.mp4#audio:lang=eng:name=" -add "H:\Subtitles.ttxt:txtflags=0xC0000000:lang=eng:name=" -new "H:\Output.mp4" I tried to add those subs in one video, the ttxt subs work somehow... but the subs settings are nor respected in MPC-HC, MPC-BE or VLC, they are rendered but with the players settings for font and position... Might work with quicktime player or something else idk. - The easiest solution i think is to still use MP4box to remux your mp4 and add a simple .srt subtitle with this inside it : Code:
1 00:01:23,000 --> 00:03:44,000 foobar testtext Code:
MP4Box.exe -add "H:\inputFile.mp4#video" -add "H:\inputFile.mp4#audio:lang=eng:name=" -add "H:\Subtitles.srt:txtflags=0xC0000000:lang=eng:name=" -new "H:\Output.mp4" The font will be default one set in the player, same for position but most of them use something like Arial and bottom of video for the font and position. Other solution might be to remux the mp4 into a MKV using .ass subtitles formated exactly like you want, I am not much familiar with ass subtitles but i guess they offer more liberties for those specific needs, but i'm not 100% sure if all players will respect the font settings tho... Sadly MP4 container does not support those .ass if i make no error, at least mp4box does not. Well... it depends of your needs and how you want to distribute the video since most subtitles parameters will probably be overwritten by the players settings used for the subs... Very last solution is to hardcode the text but it's really not worth it imo, a simple .srt subtitle ( or the .ttxt subtitle in example ) and file remuxed with MP4Box will be the most efficient and quick thing to do i think. Last edited by Yanak; 17th December 2018 at 11:33. |
|
|
|
![]() |
|
|