Hardcoding SRT subtitles onto MP4 video

The place for all kinds of software for all kinds of operating systems.

Moderator: Dposcorp

Hardcoding SRT subtitles onto MP4 video

Postposted on Wed May 14, 2014 6:29 pm

This really shouldn't be so difficult, but apparently it is. Handbrake lacks this functionality, despite having a specific feature to add subtitles via SRT file. VLC supposedly has a conversion option that allows hardcoding of SRT files, but when I tried that, the audio wouldn't play through Windows Media Player, only through VLC, and even then, the subtitles still were not in the video.

All I want to do is take the MP4 video file and hardcode the subtitles into the video so that it will play without issue on anything that can play an MP4 video, such as game consoles. I'm getting frustrated at this point and there has to be a solution out there, any help is greatly appreciated
internetsandman
Gerbil
 
Posts: 74
Joined: Wed Jul 01, 2009 2:55 am

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Wed May 14, 2014 6:37 pm

I checked some of the foreign films I have encoded with Handrake into MP4 and the subtitles are there and hard coded, but they're not available in WMP only in VLC. I think that WMP doesn't support hardcoded subtitle tracks in MP4s if I recall correctly, WMC does however.

Edit: I'm saying hard-coded but I really mean embedded, from your post I was guessing you really meant embedded. Disregard my post if I'm wrong.
Intel Core i5-4670K | Asus Z87-A | G.Skill 8GB 2400MHz CL10 | Asus DirectCU II R9 290 4GB | Samsung 840 120GB |Thermalright Macho | Lancool PC-K59
puppetworx
Gerbil Elite
Silver subscriber
 
 
Posts: 522
Joined: Tue Dec 02, 2008 5:16 am

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Wed May 14, 2014 7:17 pm

puppetworx wrote:I checked some of the foreign films I have encoded with Handrake into MP4 and the subtitles are there and hard coded, but they're not available in WMP only in VLC. I think that WMP doesn't support hardcoded subtitle tracks in MP4s if I recall correctly, WMC does however.

Edit: I'm saying hard-coded but I really mean embedded, from your post I was guessing you really meant embedded. Disregard my post if I'm wrong.


I honestly don't know what the difference is, I just want the subtitles baked into the video feed so that I don't have to depend on the player to be able to see them in order to understand foreign language sections of a movie or something
internetsandman
Gerbil
 
Posts: 74
Joined: Wed Jul 01, 2009 2:55 am

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Wed May 14, 2014 8:19 pm

Yeah, you mean hardcoded then, I misinterpreted.

Hardcoded means 'baked in' as you say, rather than being additional data that you can turn on and off they're actually encoded as part of the video. Embedded means that they're additional overlaying data which you can turn on and off, they exist alongside the video and audio data in the same file.

You need to burn them in at the encoding stage, adding them after encoding just embeds them. This should be possible by adding the subtitle track in Handbrake and checking the 'Burned In' box.
Intel Core i5-4670K | Asus Z87-A | G.Skill 8GB 2400MHz CL10 | Asus DirectCU II R9 290 4GB | Samsung 840 120GB |Thermalright Macho | Lancool PC-K59
puppetworx
Gerbil Elite
Silver subscriber
 
 
Posts: 522
Joined: Tue Dec 02, 2008 5:16 am

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Wed May 14, 2014 9:59 pm

I have used mediacoder (http://www.mediacoderhq.com/download.htm) in the past for pretty much your scenario.

I had some high-res anime in .MKV format that had softsubs but I wanted to play it back on my phone but didnt really have the software on the phone (at the time) to play it back properly.

I kept the subs and quality was very good on the phone.
RtFusion
Gerbil
 
Posts: 12
Joined: Tue Jul 27, 2010 9:46 pm

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Thu May 15, 2014 12:15 am

puppetworx wrote:Yeah, you mean hardcoded then, I misinterpreted.

Hardcoded means 'baked in' as you say, rather than being additional data that you can turn on and off they're actually encoded as part of the video. Embedded means that they're additional overlaying data which you can turn on and off, they exist alongside the video and audio data in the same file.

You need to burn them in at the encoding stage, adding them after encoding just embeds them. This should be possible by adding the subtitle track in Handbrake and checking the 'Burned In' box.


I see no 'burn in' checkbox in the box with the relevant SRT file to be encoded in; there's a default checkbox, but the only burn in checkbox appears when I click the 'add' button, which adds a subtitle box with no option to include a subtitle file associated with it, just a 'foreign language scan' as the source.

RtFusion wrote:I have used mediacoder (http://www.mediacoderhq.com/download.htm) in the past for pretty much your scenario.

I had some high-res anime in .MKV format that had softsubs but I wanted to play it back on my phone but didnt really have the software on the phone (at the time) to play it back properly.

I kept the subs and quality was very good on the phone.


Thanks for the suggestion, I'll check it out now

Edit: Damn that application is complex, I tried it out for a bit but it wouldn't let me even start the encode and tbh it's way too daunting for this tired brain at this hour. Like I said I would have thought there would be a simple solution to this lol
internetsandman
Gerbil
 
Posts: 74
Joined: Wed Jul 01, 2009 2:55 am

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Thu May 15, 2014 12:48 am

Before finding that software, I too was looking for ways to playback anime on my phone and beam it to my TV (sadly, after the last update from Samsung for my SGS2 *Rogers LTE Model*, that feature has been removed) with no worries of subtitle issues.

Mediacoder was the best option that I found after many days looking. You can use the built in Wizard to guide you on what you want, the options provided are a lot. I usually had it all untouched, nothing downscaled and only had the subtitles captured to be hardcoded.

Do note however that (at least in my case) 10-bit encodes that have the softsubs won't appear after transcoding to whatever container you use, will only work with 8-bit encodes if you want the subtitles hardcoded.

As for playback, no issues with MPHC+Klite Codec Pack (although MPCHC by itself will play a bunch of files without codec packs). Used to use VLC quite a bit but had some quirky usability issues which made me move to MPHC.

EDIT: If you want to playback to a PS3 (assuming you have one), there is software called PS3 Media Server (http://www.ps3mediaserver.org/) but I had to do a lot of tinkering around to get subs shown from the PS3. Plus, you PC needs to be fast and so does your network as it does the transcoding on the fly, so it will be resource heavy on your PC. I no longer do this method. If I really wanted to playback anime on the TV (much of them are 10-bit encodes now), I would have to hook it up the laptop to the TV. Thankfully, there is wi-fi enabled mouse.keyboard control for android phones.

Similarly, UMS (http://www.universalmediaserver.com/) touts subtitle support which works provided that you have a separate .SRT (or other subtitle file) in the same directory as the video. You can use MKV Extract to get the subs out. Needed a replacement for PC ShareManager from Samsung as that doesn't support playing content off an External drive and using Symbolic links to fool it has at times made the entire storage subsystem to freeze forcing me to do a hard reset.
RtFusion
Gerbil
 
Posts: 12
Joined: Tue Jul 27, 2010 9:46 pm

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Thu May 15, 2014 1:27 am

RtFusion wrote:Before finding that software, I too was looking for ways to playback anime on my phone and beam it to my TV (sadly, after the last update from Samsung for my SGS2 *Rogers LTE Model*, that feature has been removed) with no worries of subtitle issues.

Mediacoder was the best option that I found after many days looking. You can use the built in Wizard to guide you on what you want, the options provided are a lot. I usually had it all untouched, nothing downscaled and only had the subtitles captured to be hardcoded.

Do note however that (at least in my case) 10-bit encodes that have the softsubs won't appear after transcoding to whatever container you use, will only work with 8-bit encodes if you want the subtitles hardcoded.

As for playback, no issues with MPHC+Klite Codec Pack (although MPCHC by itself will play a bunch of files without codec packs). Used to use VLC quite a bit but had some quirky usability issues which made me move to MPHC.

EDIT: If you want to playback to a PS3 (assuming you have one), there is software called PS3 Media Server (http://www.ps3mediaserver.org/) but I had to do a lot of tinkering around to get subs shown from the PS3. Plus, you PC needs to be fast and so does your network as it does the transcoding on the fly, so it will be resource heavy on your PC. I no longer do this method. If I really wanted to playback anime on the TV (much of them are 10-bit encodes now), I would have to hook it up the laptop to the TV. Thankfully, there is wi-fi enabled mouse.keyboard control for android phones.

Similarly, UMS (http://www.universalmediaserver.com/) touts subtitle support which works provided that you have a separate .SRT (or other subtitle file) in the same directory as the video. You can use MKV Extract to get the subs out. Needed a replacement for PC ShareManager from Samsung as that doesn't support playing content off an External drive and using Symbolic links to fool it has at times made the entire storage subsystem to freeze forcing me to do a hard reset.


What I'm trying to do is encode a subtitle file onto an MP4 file, and load it onto a NAS to stream over my network to my TV (either to a smart TV or to a game console), plus streaming over the network to a mobile device, so I basically need it to be a simple MP4 file with hardcoded subs, so that all the server has to do is provide the file, and all the client has to do is play back the file, and I can understand whatever is being said in non-english portions of the video.

I went through the setup wizard that Mediacoder gave me, and I knew pretty much what all of the options were, and tailored it to what I needed and what my computer could do (nvidia CUDA, because I have a GTX 680 and I thought it would be nice to leverage that power) but when it came time to start the transcode, after I had selected the video file and SRT file, it wouldn't start the encode, telling me the coder or something wasn't available, even though it was and had been detected.
internetsandman
Gerbil
 
Posts: 74
Joined: Wed Jul 01, 2009 2:55 am

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Thu May 15, 2014 7:08 pm

Bump. Still looking for a solution :(
internetsandman
Gerbil
 
Posts: 74
Joined: Wed Jul 01, 2009 2:55 am

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Thu May 15, 2014 9:18 pm

Yeah it seems I was wrong again, that's strike two for me in this thread. :D

If you're using an srt file as a source you cannot burn in, the only supported subtitle formats for burning in according to the Handbrake wiki are sub, pgs and ssa. Given that info I googled and found this: http://forum.videohelp.com/threads/345198-Burned-in-subtitles-help. You have to first convert the .srt to .ssa using SubtitleEdit, then mux the .ssa with your mp4 using mkvmerge, then you can finally encode and burn in the subs with Handbrake. I checked and this method definitely does work, it sounds lengthy but the first two steps are very quick.
Intel Core i5-4670K | Asus Z87-A | G.Skill 8GB 2400MHz CL10 | Asus DirectCU II R9 290 4GB | Samsung 840 120GB |Thermalright Macho | Lancool PC-K59
puppetworx
Gerbil Elite
Silver subscriber
 
 
Posts: 522
Joined: Tue Dec 02, 2008 5:16 am

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Fri May 16, 2014 12:59 am

If you don't mind using a longer route, you can always use something like subtitle workshop, change the srt into something that works in handbrake, then do steps in handbrake, click on burn in. there you are, problem solved.
toki
Gerbil
 
Posts: 26
Joined: Fri Nov 08, 2013 3:55 pm

Re: Harcoding SRT subtitles onto MP4 video

Postposted on Fri May 16, 2014 1:02 am

^ The "Import SRT" button on Handbrake's Subtitle handling section actually allows you to load an SRT file without having to mux it in to your source.

Back in the day this hardcoded subs thing used to be done with Virtualdub, plus Vobsub (or your preferred subtitle plugin). More savvy encoders might have used an Avisynth server.
jihadjoe
Gerbil Team Leader
 
Posts: 288
Joined: Mon Dec 06, 2010 11:34 am

Re: Hardcoding SRT subtitles onto MP4 video

Postposted on Tue Nov 18, 2014 5:30 am

Sorry to bump a topic from a while ago, but I figured in case it helps anybody, this might be worth a mention: I got this to work using VidCoder Beta v1.5.27.9 (x86).

I had pretty much the exact same problem as the original author of this thread:

internetsandman wrote:This really shouldn't be so difficult, but apparently it is. Handbrake lacks this functionality, despite having a specific feature to add subtitles via SRT file. VLC supposedly has a conversion option that allows hardcoding of SRT files, but when I tried that, the audio wouldn't play through Windows Media Player, only through VLC, and even then, the subtitles still were not in the video.

All I want to do is take the MP4 video file and hardcode the subtitles into the video so that it will play without issue on anything that can play an MP4 video, such as game consoles. I'm getting frustrated at this point and there has to be a solution out there, any help is greatly appreciated


I needed to hardcode (or "burn") subtitles into an mp4 video with H.264 + AAC encoding, in order to play it on my Xbox 360 - which, as we all unfortunately know, does not support external subtitle files. I had tried a number of things over the course of two days including the following, which seemed most promising because of their popularity and frequency in forums, though they all turned out to be completely useless to me:
  • VLC's convert function
  • Handbrake
  • and the opensource tool AVIaddXSub
I found a discussion on forum.videohelp.com (Topic: How-to-easily-burn-in-hardcode-srt-subtitles-to-mp4-mkv-with-VidCoder, by Baldrick - since I cannot post URLs) about this program called VidCoder, with a complete tutorial on how to use it, screenshots included. The GUI is pretty straightforward and simple to use, but also has advanced settings in case you're a pro (which I am NOT) and want to play around with it.

Turned out, it was exactly what I needed, BUT it might not work for everyone - especially if you are trying to hardcode subtitles using non-UTF-8 characters (in general, scripts other than English). For those situations, it seems like VidCoder is still a work in progress, at least the version being discussed in the forum. The output options are also limited to MP4 and MKV, but again this was fine for me when running the finished video on an Xbox 360. If you are interested in hardcoding standard English subtitles from SRT files, this might be a good option for you.

Just a quick synopsis of what is discussed in the forum mentioned above:
  1. Choose a source video file.
  2. Specify a subtitle track by importing an SRT file.
  3. Select an output path.
  4. (Optional) You can mess with the Encoding Settings. From the discussion, it looked like some people had to change the audio stream to get the final product to work properly, but that was also for an older version of the program; I didn't have to do any of that - AAC worked fine.
  5. (Optional) Specify a 'Preset', such as Android, Apple iPod, and even Xbox 360!
  6. Encode and wait until it's finished.
I was also super frustrated when I first started exploring this problem of devices not being able to read SRT files. I have since learned that re-encoding video is not as trivial as I thought it would be. Looks like a lot of things can go awry and cause your video to not play in certain devices. For instance, the MP4 file I had been working with never played on my PS3, though it worked on Xbox 360 and VLC. This was true regardless of whether I repackaged it as an AVI or MKV. So it seems that even though a file contains an extension like AVI or MP4 that should be playable by a given device, these zipping/unzipping actions are not guaranteed to encode your data in a format that can be properly read by that device. Whether or not some solution works for you depends on the total encapsulated package rather than on just the file extension.

Anyway, glad I found this program. I'm going to tinker around more with this, later. Not sure if it will help anyone, but it definitely got the job done for me.

I'm now wondering how Netflix or Amazon Video encode their optional subtitles. And if they can do it, how hard would it be to write a video player app for Xbox or PS3 that reads SRT files and gives the option of displaying subtitles? Clearly, a discussion for a different thread :D.
sushiSakana
Gerbil In Training
 
Posts: 2
Joined: Tue Nov 18, 2014 4:18 am

Re: Hardcoding SRT subtitles onto MP4 video

Postposted on Tue Nov 18, 2014 6:55 am

I use format factory.
If a SRT file exists, it is automatically hard coded into the converted file.
rahulahl
Gerbil
Silver subscriber
 
 
Posts: 91
Joined: Thu Aug 16, 2012 8:57 am
Location: Australia

Re: Hardcoding SRT subtitles onto MP4 video

Postposted on Tue Nov 18, 2014 4:02 pm

sushiSakana wrote:Sorry to bump a topic from a while ago, but I figured in case it helps anybody, this might be worth a mention: I got this to work using VidCoder Beta v1.5.27.9 (x86).


Please do not apologize for resurrecting a thread to post thorough, awesome, helpful information. :)

I've been searching on and off for a solution to this for quite awhile. Media Center on the HTPC is where all of my movie watching happens, and it's a MCE is a mess regarding subs. Plus, as mentioned elsewhere in this thread, I really don't want to have to rely on playback software to support SRTs to make sure I get proper playback in the future. Hardcoding seems like by far the best option.

The one really problematic thing that has been an issue for me with every program I've tried is that there's always a degradation of quality when re-encoding (I've tried too many programs to count; Handbrake, xvid4psp come to mind, but many others as well). Ideally, I want something that preserves the 720P/1080P file as it already is, rather than an entire re-encode that generally takes 4-8 hours and reduces file size/quality (encode box is an older i7 920 system running as a server) . The time I could live with if absolutely needed, but I really don't like the reduced quality/size. It seems like it would be feasible to make a program that "re-encodes" but leaves the source frames untouched other than the sub hardcoding that it's doing.

Anywho, TL;DR - did you notice a significant drop in file-size/quality with VidCoder?
divide_by_zero
Gerbil
Gold subscriber
 
 
Posts: 40
Joined: Fri May 30, 2014 8:57 pm

Re: Hardcoding SRT subtitles onto MP4 video

Postposted on Sat Nov 22, 2014 4:27 pm

Haha thanks, hope it helps others searching for solutions!

divide_by_zero wrote:Anywho, TL;DR - did you notice a significant drop in file-size/quality with VidCoder?


So the whole process took about 40-ish minutes, and the file size actually increased from ~700 MB to 1.09 GB (still in mp4 format). I didn't find any degradation of quality, though admittedly that is a qualitative observation (not sure if there is a more analytical way to measure its quality before and after, can anyone suggest any tools?). I'm adding a couple of pictures here to show a comparison:

Pre-subtitle encoding:
Image

Post-encoding:
Image

Quality doesn't look degraded to me.


It turns out VidCoder does have options to reduce the re-enconding quality if one desires to save disk space, but the default is to preserve quality. The following show what the interface looks like.

You can set your Preset preference to any one of a number of different devices:
Image

After clicking on Settings (area circled in red, above), you come to this menu where you have more ability to tweak output quality:
Image

Hope that answers your question!
sushiSakana
Gerbil In Training
 
Posts: 2
Joined: Tue Nov 18, 2014 4:18 am

Re: Hardcoding SRT subtitles onto MP4 video

Postposted on Sat Nov 22, 2014 4:32 pm

I would do this with AviSynth. You can hardcode any subtitle format if you can just get the scripts to work, or generate the scripts automatically. But ever since HandBrake came out with ASS hardcoding support, I haven't played with AviSynth much.
Mothership: Thuban 1055T@3.7GHz, 12GB DDR3, M5A99X EVO, GTX470+Icy Vision Rev.2@840/3800, Vertex 2E 60GB
Supply ship: Sargas@2.8GHz, 12GB DDR3, M4A88TD-V EVO/USB3
Corsair: Macbook Air Ivy Bridge
Crayon Shin Chan
Minister of Gerbil Affairs
 
Posts: 2253
Joined: Fri Sep 06, 2002 11:14 am
Location: Malaysia


Return to General Software

Who is online

Users browsing this forum: No registered users and 3 guests