From 249682cda42192de79a605f8b759ecf35bd27193 Mon Sep 17 00:00:00 2001 From: Michael Higgins Date: Tue, 15 Apr 2014 18:53:53 -0400 Subject: [PATCH] embed-subs option Added an option to disable embedding of subtitle tracks. Downloaded tracks will remain as external SRT files if this option is enabled. --- README.md | 1 + autoProcess.ini.sample | 1 + mkvtomp4.py | 7 +++++-- readSettings.py | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4f9a0364..e3cbc3ed 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ General Installation Instructions - `tagfile` = True/False - Enable or disable tagging file with appropriate metadata after encoding. - `download-artwork` = True/False - Enabled downloading and embeddeding of Season or Movie posters and embeddeding of that image into the mp4 as the cover image. - `download-subs` = True/False - When enabled the script will attempt to download subtitles of your specified languages automatically using subliminal and merge them into the final mp4 file. + - `embed-subs` = True/False - Enabled by default. Embeds subtitles in the resulting MP4 file that are found embedded in the source file as well as external SRT files. Disabling this means you will lose embedded subtitles from the source video file (they will not be externalized to SRT files). The script will still attempt to download an external subtitle file however if the option is enabled to do so. **YOU MUST INSTALL SUBLIMINAL AND ITS DEPENDENCIES FOR THIS TO WORK.** You must go into the `setup\subliminal` directory included in this script and run `setup.py install` to add support for fetching of subtitles. The version included with this script is modified from the stock version of subliminal, so you must install the included version. - `sub-providers` = Comma separated values for potential subtitle providers. Must specify at least 1 provider to enable `download-subs`. Providers include `podnapisi` `thesubdb` `opensubtitles` `tvsubtitles` `addic7ed` diff --git a/autoProcess.ini.sample b/autoProcess.ini.sample index 7cf62e87..5550752a 100644 --- a/autoProcess.ini.sample +++ b/autoProcess.ini.sample @@ -36,6 +36,7 @@ convert-mp4=False tagfile=True download-artwork=True download-subs=False +embed-subs=True sub-providers=addic7ed,podnapisi,thesubdb,opensubtitles [CouchPotato] diff --git a/mkvtomp4.py b/mkvtomp4.py index 0e24cd80..163cbb7c 100644 --- a/mkvtomp4.py +++ b/mkvtomp4.py @@ -31,6 +31,7 @@ def __init__( self, settings=None, processMP4=False, copyto=None, moveto=None, + embedsubs=True, providers=['addic7ed', 'podnapisi', 'thesubdb', 'opensubtitles']): # Settings self.FFMPEG_PATH=FFMPEG_PATH @@ -57,6 +58,7 @@ def __init__( self, settings=None, self.sdl=sdl self.downloadsubs = downloadsubs self.subproviders = providers + self.embedsubs = embedsubs # Import settings if settings is not None: self.importSettings(settings) @@ -88,6 +90,7 @@ def importSettings(self, settings): self.sdl=settings.sdl self.downloadsubs=settings.downloadsubs self.subproviders=settings.subproviders + self.embedsubs=settings.embedsubs # Process a file from start to finish, with checking to make sure formats are compatible with selected settings def process(self, inputfile, reportProgress=False, original=None): @@ -224,7 +227,7 @@ def generateOptions(self, inputfile, original=None): print "Subtitle stream detected: " + s.codec + " " + s.language + " [Stream " + str(s.index) + "]" # Make sure its not an image based codec - if s.codec not in bad_subtitle_codecs: + if s.codec not in bad_subtitle_codecs and self.embedsubs: # Set undefined language to default language if specified if self.sdl is not None and s.language == 'und': s.language = self.sdl @@ -283,7 +286,7 @@ def generateOptions(self, inputfile, original=None): except: pass # If subtitle file name and input video name are the same, proceed - if x == filename: + if x == filename and self.embedsubs: print "External subtitle file detected, language " + lang if self.swl is None or lang in self.swl: print "Importing %s subtitle stream" % (fname) diff --git a/readSettings.py b/readSettings.py index d74f684e..2ff396c3 100644 --- a/readSettings.py +++ b/readSettings.py @@ -43,6 +43,7 @@ def __init__(self, directory, filename): 'tagfile': 'True', 'download-artwork': 'True', 'download-subs': 'False', + 'embed-subs': 'True', 'sub-providers': 'addic7ed, podnapisi, thesubdb, opensubtitles' } # Default settings for CouchPotato cp_defaults = {'host': 'localhost', @@ -156,6 +157,8 @@ def __init__(self, directory, filename): else: self.subproviders = self.subproviders.lower().replace(' ', '').split(',') + self.embedsubs = config.getboolean(section, 'embed-subs') + self.vcodec = config.get(section, "video-codec") if self.vcodec == '': self.vcodec == ['h264', 'x264']