Zone38 Presents...
Letters to the World

28-Jul-2010

Subtitles for Netflix, à la Python

Filed under: Programming — codeman38 @ 10:29 pm

So I just read this post by Josh Erickson in which he discovered a super-secret feature of Netflix’s web player: the ability to load an external subtitle file for any streaming video. This is huge— basically, after converting them to the proper format, you’re able to overlay subtitles from a site like OpenSubtitles over any of the many uncaptioned videos from Netflix.

Here’s the trick: Press Ctrl+Shift+Alt+M to display a secret diagnostic menu. One of the options shown there is “Load Custom DFXP File”, from which you can load a custom subtitle script in W3C Timed Text format.

But how do we get subtitles into this DFXP format? Well, in the link above, Josh Erickson took the time to write a Windows PowerShell script to convert SubRip files to that format, with all of the necessary quirks to make Netflix’s player recognize it (a harder task than one would think, as the parser is about as finicky as I sometimes can be).

That’s great… if you’re using Windows. But there’s a certain other platform that Netflix fully supports which isn’t able to run that script— at least not without installing Windows in a dual-boot partition or VM, anyway.

Thankfully, I’m also somewhat experienced in Python, which is natively supported in Mac OS X. And so, I decided to port the script to Python.

Here’s the Python version of srt2dfxp.

It’s a command-line-only script for now, much like Erickson’s original; run it without any parameters and it will let you know the syntax. For creating files for use with the Netflix player, the -n option is most important; this is the one that forces the output to use Netflix-specific formatting quirks. The -t option is also useful; it will add a delay of whatever number of seconds comes after -t, to allow for differences in starting time due to things like the Starz logo.

Here’s an example of how to use the program:

./srt2dfxp.py -n -t15 holygrail.srt holygrail.dfxp

will convert holygrail.srt to holygrail.dfxp in Netflix-compatible format, with a delay of 15 seconds added to all time stamps.

(And yes, I used that filename in the example for a reason. This is a Python script, after all! ^_~)

I’ve tested it, and it seems to work with streaming on my MacBook. Let me know if you experience any issues with it!

Edited to add: Two minor bug fixes that I’ve already worked in: convert & to & so Netflix doesn’t choke on ampersands in the output, and don’t crash on the UTF-8 byte order marker if it’s present.

Edited 2010/08/26: Updated to version 1.3. Fixed another stupid mistake– time offsets are no longer rounded to the nearest integer.

Edited 2010/09/30 to add: As David points out in comment #14 below, the XML output from Jubler works perfectly well with Netflix! I’ve just tested this, and confirmed it. This is extremely helpful for having to deal with subtitles with incorrect frame rates or non-SubRip subtitle formats, though you can use it as to convert correctly timed SRT files just as easily.

21 Comments »

  1. […] Codeman38 has created Python version that works on Macs and I assume Linux. Posted in code, powershell | Tags: close, dfxp, Instant […]

    Pingback by Netflix subtitles | Josh Erickson — 29-Jul-2010 @ 12:44 pm

  2. […] reading Codeman38‘s blog edit I figured I can’t leave my Windows brethren behind in the dust when it […]

    Pingback by Srt2DFXP v0.2 and a GUI! | Josh Erickson — 29-Jul-2010 @ 11:22 pm

  3. Thank you for your help. I went to Josh’s site and could follow his guide. Much grateful.

    Comment by Osvaldo — 24-Aug-2010 @ 12:44 am

  4. @Osvaldo: Glad I could help! This is a feature that seriously needs to be publicized more, since Netflix and/or the studios can’t be bothered to provide their own subtitle files when the feature exists…

    Comment by codeman38 — 24-Aug-2010 @ 12:46 am

  5. This is awesome. I’m on a Mac platform so I downloaded the Python script in the comments above & it looks like I’m able to convert the SRT to DFXP, but when I try to load it in the player menu, I get “Custom: Not Supported”. I got the SRT from opensubtitles.org. Just hoping to get some troubleshooting steps…

    Comment by Chris — 29-Aug-2010 @ 11:23 am

  6. @Chris: There’s probably a formatting error in the subtitle, like an italics tag that’s opened or closed twice. I’ve had this issue with a few subs from SubScene.

    Comment by codeman38 — 29-Aug-2010 @ 11:25 am

  7. @codeman38 You’re right. I played around with it some more and realized I could get it to work. Depends on the subtitle I downloaded. Do you prefer any particular subtitle site over another? I also thought it’d be nice to wrap this script into a GUI via Xcode or maybe even a Safari Extension if Safari Extensions support it.

    Comment by Chris — 06-Sep-2010 @ 1:18 pm

  8. @Chris: No preference on subtitle sites; I’ve used SubScene, OpenSubtitles and TVSubtitles depending on the movie/show.

    I’ve actually been considering writing a GUI wrapper for it myself, when I actually have some time to do that – though you’re welcome to contribute anything; I should set up a GitHub site or something. Don’t know if a Safari extension would be so easy, at least if you’re wanting to convert subtitles directly from downloads; most of the sites I’ve seen zip their subtitle files before transferring them, and I’m not entirely sure Safari extensions can handle that.

    Comment by codeman38 — 06-Sep-2010 @ 1:22 pm

  9. @codeman38 I’d definitely be interested in helping make a GUI, only problem is I’ve never done it before. 🙂 This would be as good a motivation as any to learn though. Such as, at first the plan would be to get a GUI working & then maybe later add the ability to search for & download the subtitles, by searching the main subtitle sites.

    One of the major issues I’m having is getting the timing right. Seems to take me quite a few times. That’s why I wonder if any one subtitle is better than another.

    Comment by Chris — 06-Sep-2010 @ 1:41 pm

  10. @Chris: Yeah, my GUI experience is mainly in Linux (GTK) and Windows (WinForms). I’ve toyed around with designing GUIs in Interface Builder a bit, but I still need to learn how to interface that with Python.

    As for timing, my experience has been that the timing is pretty much the same on all the sites. Typically the issue is that Netflix gets a different print from the studios for streaming than what’s used on the DVD.

    Comment by codeman38 — 06-Sep-2010 @ 4:33 pm

  11. Would it be possible for you to post a few screenshots of what it should look like before and after you run the command? I’m not very tech-savvy and I’m having trouble figuring out what I’m supposed to type to get the program to work. I’m typing in what’s shown on this page but with a different file name and it’s just not working! Also, where is the .srt supposed to be saved to so that the program can find it?

    Comment by shelly — 23-Sep-2010 @ 10:28 am

  12. @shelly: If you’re not familiar with the Terminal, the best idea is to put both the .srt and the Python script in your home directory. Then it should work pretty much as described. If that doesn’t work, try “python srt2dfxp.py” instead of “./srt2dfxp.py”.

    I really need to write a GUI version, but I’m far too busy with other stuff to really be able to concentrate on it– the shell-script version used enough of my time.

    Comment by codeman38 — 23-Sep-2010 @ 10:30 am

  13. […] which means Windows only, but a talented Python developer also found the same blog ahead of me and ported the script to python for us Mac OS or Linux users.  Also worth noting that Josh has developed a GUI for the script that […]

    Pingback by Netflix Subtitles « Hearn's Blog — 27-Sep-2010 @ 6:30 pm

  14. I think I might be able to save some you some time on the GUI project. There’s an easy way to convert the .srt files to .dfxp. (I was trying to fix the “Custom: Not Supported” problem and stumbled across it)
    1. Download Jubler from http://www.jubler.org/
    2. Open the subtitle file you wish to convert in Jubler
    3. Save the file in a W3C Timed Text format with UTF-8 encoding
    4. Change the extension of your newly created file to .dfxp

    Comment by David — 30-Sep-2010 @ 5:14 pm

  15. @David: Ooh, good catch! I’ve even used Jubler, and never noticed that its DFXPs were Netflix-compatible.

    Comment by codeman38 — 30-Sep-2010 @ 10:48 pm

  16. @David — Nice catch! It doesn’t seem to be working on my Mac at the moment.. When I convert the file and rename it, Netflix doesn’t recognize the file. Could this be a mac thing?

    Comment by DaFyre — 14-Nov-2010 @ 1:22 am

  17. @DaFyre: Make sure that you’re saving it with UTF-8 encoding.

    Comment by codeman38 — 14-Nov-2010 @ 1:31 am

  18. […] which means Windows only, but a talented Python developer also found the same blog ahead of me and ported the script to python for us Mac OS or Linux users.  Also worth noting that Josh has developed a GUI for the script that […]

    Pingback by Netflix Subtitles | churnd — 18-Nov-2010 @ 7:42 pm

  19. I was having a few issues with certain sub files on certain videos, but I noticed that other sub files would work on those videos. I eventually discovered that ampersands were apparently causing the problem, because whenever I removed them in Jubler, the files worked fine. I noticed up there that you mentioned that this is a problem you fixed with your method of converting sub files, but I’ve been using Jubler; is there any chance that you might know how to alleviate the problem in Jubler? You know, so I can keep the ampersands without messing up the sub file? Because, right now I’ve just swapped them out for the word ‘and’, but that doesn’t look nice. Which I realize sounds very nitpicky, but if it can be fixed-then why not, I figure.

    Oh, and I also want to say thanks for all the effort you put into figuring out subtitles for Netflix on Mac OSX. It is MUCH appreciated.

    Comment by Osman — 14-Mar-2011 @ 1:51 am

  20. Hi there. I am using jubler, but when I select the save as option the save subtitles window opens, but it only has a drop off menu for encoding. There is no way to select the format. Therefore I am saving it as UTF8 and adding the dfxp extension to the name, but when I uploaded it to Netflix it doesn’t show anything. Any body can help me with that? Thanks

    Comment by Mauricio — 17-Dec-2013 @ 6:47 am

  21. […] Manchmal kann es aber auch passieren, dass man einen ausländischen Film schauen will, den es noch nicht in deutscher Synchronisation gibt. Mit einem kleinen Tool namens Jubler kann man Untertitel im SRT-Format kurzerhand in das von Netflix genutzte DFXP-Format konvertieren und nutzen. […]

    Pingback by Netflix: 16 praktische Tipps für den Streaming-Dienst — 17-Dec-2015 @ 1:42 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

You can use these HTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

© 2001-2017 codeman38. Powered by WordPress.