Personal computing discussed

Moderators: renee, Dposcorp

 
internetsandman
Gerbil First Class
Topic Author
Posts: 115
Joined: Wed Jul 01, 2009 2:55 am

Hardcoding SRT subtitles onto MP4 video

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
 
puppetworx
Gerbil Elite
Posts: 710
Joined: Tue Dec 02, 2008 5:16 am

Re: Harcoding SRT subtitles onto MP4 video

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.
 
internetsandman
Gerbil First Class
Topic Author
Posts: 115
Joined: Wed Jul 01, 2009 2:55 am

Re: Harcoding SRT subtitles onto MP4 video

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
 
puppetworx
Gerbil Elite
Posts: 710
Joined: Tue Dec 02, 2008 5:16 am

Re: Harcoding SRT subtitles onto MP4 video

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.
 
RtFusion
Gerbil
Posts: 17
Joined: Tue Jul 27, 2010 9:46 pm

Re: Harcoding SRT subtitles onto MP4 video

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.
 
internetsandman
Gerbil First Class
Topic Author
Posts: 115
Joined: Wed Jul 01, 2009 2:55 am

Re: Harcoding SRT subtitles onto MP4 video

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
 
RtFusion
Gerbil
Posts: 17
Joined: Tue Jul 27, 2010 9:46 pm

Re: Harcoding SRT subtitles onto MP4 video

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.
 
internetsandman
Gerbil First Class
Topic Author
Posts: 115
Joined: Wed Jul 01, 2009 2:55 am

Re: Harcoding SRT subtitles onto MP4 video

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 First Class
Topic Author
Posts: 115
Joined: Wed Jul 01, 2009 2:55 am

Re: Harcoding SRT subtitles onto MP4 video

Thu May 15, 2014 7:08 pm

Bump. Still looking for a solution :(
 
puppetworx
Gerbil Elite
Posts: 710
Joined: Tue Dec 02, 2008 5:16 am

Re: Harcoding SRT subtitles onto MP4 video

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.
 
toki
Gerbil XP
Posts: 353
Joined: Fri Nov 08, 2013 3:55 pm

Re: Harcoding SRT subtitles onto MP4 video

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.
 
jihadjoe
Gerbil Elite
Posts: 835
Joined: Mon Dec 06, 2010 11:34 am

Re: Harcoding SRT subtitles onto MP4 video

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.
 
sushiSakana
Gerbil In Training
Posts: 2
Joined: Tue Nov 18, 2014 4:18 am

Re: Hardcoding SRT subtitles onto MP4 video

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.
 
rahulahl
Gerbil Team Leader
Posts: 256
Joined: Thu Aug 16, 2012 8:57 am
Location: Australia

Re: Hardcoding SRT subtitles onto MP4 video

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.
Intel i7 4790K
MAXIMUS VII RANGER motherboard
EVGA GTX 1080
16GB Ram
550Watt Seasonic PSU
Asus Rog Swift PG278Q
Windows 10
 
divide_by_zero
Gerbil First Class
Posts: 117
Joined: Fri May 30, 2014 8:57 pm

Re: Hardcoding SRT subtitles onto MP4 video

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?
 
sushiSakana
Gerbil In Training
Posts: 2
Joined: Tue Nov 18, 2014 4:18 am

Re: Hardcoding SRT subtitles onto MP4 video

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!
 
Crayon Shin Chan
Minister of Gerbil Affairs
Posts: 2313
Joined: Fri Sep 06, 2002 11:14 am
Location: Malaysia
Contact:

Re: Hardcoding SRT subtitles onto MP4 video

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: FX-8350, 12GB DDR3, M5A99X EVO, MSI GTX 1070 Sea Hawk, Crucial MX500 500GB
Supply ship: [email protected], 12GB DDR3, M4A88TD-V EVO/USB3
Corsair: Thinkpad X230
 
jbwtucker
Gerbil In Training
Posts: 1
Joined: Sat Jan 17, 2015 8:56 pm

Re: Hardcoding SRT subtitles onto MP4 video

Sat Jan 17, 2015 9:17 pm

I was able to accomplish this using Handbrake. Or at least, something that worked for my purposes. Didn't require any additional apps. You just have to select the right settings, and it's counterintuitive. You DON'T select "Burned In" — you select "Default."

I'm using this for the purpose of displaying subtitles on a video file that I downloaded, watching on an Apple TV 2 connected to the iTunes media library on my Macbook Air. Simply having an identically named .srt file in the same directory as the video file does not work; neither iTunes nor Apple TV will display the subtitles if you do this, the way other video players do (MPlayerX, VLC, etc.).

The settings I used in Handbrake enabled me to re-encode the file with subs embedded—they do not show up automatically, but both in iTunes on the computer and on the Apple TV, the subs were there when I went to turn them on.

So it's a pretty specific context. I haven't tried using this file in any other app (this is all I need it for), let alone on any other platform, so you know... YMMV. I know others of you are trying to do things with your phones, etc., perhaps with apps that don't have a subtitle feature AT ALL—in that case, this may not help you. For me, this was about apps/devices that I know can display subtitles (iTunes and the Apple TV), but I couldn't do it with files I had downloaded. This fixed that for me.

ANYHOW, here's what I found. This method is taken from this unnecessarily long YouTube video: youtube.com/watch?v=63D6mRMt8PQ

It really doesn't need to be 8 minutes long. It's really this simple:

  1. Open your file in Handbrake
  2. Go to the Subtitles tab
  3. Select to Add External SRT...
  4. Check Default, NOT Burned In
  5. Make sure the proper language is selected
  6. Click Play (or Add to Queue)

Done. For me, that worked. Import the new video file into iTunes. No .srt file is present in the directory. Subtitles can be turned on in iTunes, and on my Apple TV 2, as well.

Hope that helps. Maybe it will work for whatever others of y'all are trying to do, as well. And since it's all done within Handbrake, video encoding settings can be whatever you want them to be.

Before I bow out, one handy tip that I personally find extremely useful. If you're on a Mac, run your resulting video through Smart Converter Pro 2 (it's not free, but I bought it a while back, and have used it SO much I have not regretted it). It will recognize the show and episode, tag it accordingly, and convert as necessary. If you're file is already an MP4, it doesn't actually convert it, just tags it. Takes literally less than 2 seconds. It keeps everything about the original file, which means my subtitles from the previous re-encode are still there... but it doesn't mess with the video itself, meaning I haven't lost any quality. But when I import it into iTunes, not only does it go to the right section of the videos (TV Shows, instead of Home Movies), but all of the show information is already in there. It's beautiful.
 
jihadjoe
Gerbil Elite
Posts: 835
Joined: Mon Dec 06, 2010 11:34 am

Re: Hardcoding SRT subtitles onto MP4 video

Wed Nov 25, 2015 7:53 am

jbwtucker wrote:
Done. For me, that worked. Import the new video file into iTunes. No .srt file is present in the directory. Subtitles can be turned on in iTunes, and on my Apple TV 2, as well.


Those subs are muxed in to the video file, but still not hardcoded into the video itself though. If the device supports subtitle display then it's obviously a better way of doing things, but if you need to play it on a device without subtitle support then "Burned In" needs to be checked.
Also, if you just want to mux the subs into the video container so you don't have a folder full of .SRTs, then a muxer is a much better choice than Handbrake so the video doesn't get re-encoded.

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On