SOLUTION: EIA_608 Subtitles Suck - Here's how to automatically replace them with srt goodness

Server Version#: 1.15.2.793
Player Version#: n/a

So a little background first. I live in a house with deaf people, so subtitles are required. For years now I’ve been using MCEBuddy to rip the subs to an srt file, and have them inserted into mkv files. This worked great.

Recently, Plex has added the ability to display EIA_608 subtitles, which in and of itself would seem like a good thing. More subtitles is good right?

However, the display for those subs, needs a LOT of work. Frankly it makes the TV show almost unwatchable because they are too large and cover too much of the screen.

Another problem is, that since Plex now automatically detects the existence of 608 subs, it shows them as Unknown (EIA_608) and they are automatically selected when sometimes a better srt file is available.

So, I wanted to remove the 608 subs, HOWEVER keep their data, because the 608’s usually have the timing dead on (they come embedded into the video stream itself) vs grabbing subs from opensubtitle or elsewhere, where the timing and correctness can be suspect at best.

So I wrote a python script that uses ffmpeg and several other tools to rip the 608 subs to an srt file, then remove them from the video, and then merge the srt back into the file (assuming you’re using mkv files like I do).

This makes plex select the srt file automatically and it’s says ‘English’ instead of Unknown.

And this is all totally automated thanks to Tautulli’s awesome script tools.

First head over to Tautulli’s settings, and go to Notification Agents. create a new Script agent, and then fill in the following settings:

Script folder: { where you put my python script}
Script file { should let you just select it once you chose the folder above }
Script timeout 0

Under Triggers:
Check ‘Recently Added’ ( I suppose you could do more, but it’s not necessary )

Change nothing on the Conditions tab

Then under Arguments scroll down to Recently Added and enter the following:
{media_type} {file} {filename}

Then click Save.

Then all you have to do is modify the top of my script to update the specific locations, and you’re all set.

Every time new media is added, this script will run and remove those pesky 608’s and replace them with wonderful srt’s embedded in your mkv files.

I’ve tested this quite thoroughly… and it’s worked GREAT so far, for both DVR’d recordings, and recordings from ‘other’ sources too.

Let me know if you have questions or need help!

Enjoy!

{c}guy
SubProcessing.7z (1.7 KB)

12 Likes

Thanks for the post, now I need to figure out how to modify the script to work with a docker version of the Tautulli.

hbrakeoutputpath=r’G:\TempStorage\’ # Keep the r at the front and the extra ‘' at the end. (if you’re on windows)… Python Requires This.
arg1 = ‘–Language=raw’
mkvm = r’C:\Program Files\MKVToolNix\mkvmerge.exe’
mediainfo = r’C:\ccextractor\MediaInfocmd.exe’
ffmpeg = r’C:\Program Files\MCEBuddy2x\ffmpeg\ffmpeg.exe’
ccextract = r’C:\ccextractor\ccextractor.0.85b-windows.binaries\ccextractorwin.exe’
eiasubs = ‘–Output=Text;%Format%::’
temp_file = ‘C:\Users\Public\SubProcesslog.txt’

I’m not sure, but the docker version of tautulli should still have a way to start a script when new media is added to Plex. All you need to do is pass the same variables I put in my original post.

Sorry, I meant to say that I need to modify the docker container to add the applications listed in your script.

This is EXACTLY what I needed, thank you very much!!
One question, can you please tell me which are the parameters I need to pass to the python script?

I’m not installing Tautulli so I’ll trigger it manually.

Reverse engineering the code, it looks like the 3 arguments are:

  1. episode (the exact word)

  2. full file path

  3. file name

I’m on raspberry pi so I’m trying to adapt it to my OS

EDIT: I’ve tested the script and the 3 parameters looks correct. I had to fix all subprocess commands adding shell=True otherwise I was having a OSError: [Errno 2] No such file or directory. Could it be something related to the manual lunch? Is this supposed to be run in python3 or 2 ?
Also, the following line:

mkvmerge_cmd = r'C:\Program Files\MKVToolNix\mkvmerge.exe -o '+mergetemp+' '+ffmpegtemp2+' --language 0:eng '+srtfile

should be:

mkvmerge_cmd = mkvm + ' -o '+mergetemp+' '+ffmpegtemp2+' --language 0:eng '+srtfile

to obey to the program executable configured at the beginning.

Glad you found it useful! It’s definitely made my tv viewing much more enjoyable. You got the parameters correct. Enjoy!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

And you will find that the more recent CCExtractor will extract stuff right from TS files.

For example my new process for PostProcessing was something like this - until I realized it’s not giving me the file in the final destination - it’s in a temporary location - so instead I am doing it through Tautulli but similar situation.

CCExtract to grab the closed captions from TS/EIA_608 to srt
ComSKip/ComChap to find ads and put them into chapter chunks.
then mkvmerge to take ts file, merge closed captions and chapter information and output mkv file

Did you ever get this working with Docker?

Hi,

This is exactly what I need and I thought I downloaded all the needed programs on my Plex Server (win 10).
But this is missing and I cant find it anywhere: mediainfo = r’C:\ccextractor\ MediaInfocmd.exe

Can somebody tell me where I can find this file?

Thanks,

/Mats

I assume here: MediaInfo - Download MediaInfo for Microsoft Windows
(The “CLI” build)

Thanks but it doesn’t look like it. When I install from your link I get a file named MediaInfo.exe, not MediaInfocmd.exe as it says in the script.

I think he just renamed it, because the GUI version has the exact same file name, which makes it difficult to store both versions in the same folder.

But of course I could be wrong, only @Cguy1234 will know.

Yes, it’s the command line version of mediainfo which you can find here: https://mediaarea.net/en/MediaInfo/Download

Be sure to grab the CLI version for the script to work.

Enjoy!

1 Like

Thank you for your help, @OttoKerner and @Cguy1234.

I haven´t had time to try it until now and after your help it works, sometimes. :frowning:

The problem is that when it arrives more than one new video file at the same time, it tries to do all of them at the same time, and then it stops after a while, leaving the files in the temp directory without conversion.

. I can have up to 4 files (4 tuners) arriving at the same time, and they are .TS and at 1080p, up to 6-10GB per file it tends to be a lot of work for the server.

I can’t change the script myself, but maybe someone can point me in the right direction. What I would like to do is:

  1. Is there any way to get it to do the conversions after each other instead of at the same time if the files arrive at the same time? (I assume not, but I got to ask).

  2. Is there anyway to choose just either Plex libraries or file directories where it should do the conversion? Because there is just two out of 20 Plex libraries that I need this done.

  3. Is there anyway to first do a quick check if there is a EIA_608 in the video before starting to copy the videos and start the extracting? Then most of the files wont have the EIA_608 and wont need to copy or anything.

I will be very grateful for any help with this because the function is exactly what I want.

Thanks /Mats

Hey Mats,
I actually ran into this same issue on my system after using it for some time. So I modified the script to that it knows if one file is in process and ‘queues’ the rest until the first once completes.

It uses a ‘lockfile’ that’s created when the script runs, and then checks for the existence of that lockfile if the script runs again, running a loop until it doesn’t find it anymore.

I’ve been using this for months now, with no problems.

Here’s the updated script with the enhancements.

Enjoy!

{c}guy
SubProcessing.zip (2.3 KB)

1 Like

Hey {c}guy
,
I have changed to the new script now and will start testing it right away :).
Thanks!

/Mats

I have no use for this, but it sounds awesome.