Skip to content

Commit

Permalink
embed-subs option
Browse files Browse the repository at this point in the history
Added an option to disable embedding of subtitle tracks. Downloaded
tracks will remain as external SRT files if this option is enabled.
  • Loading branch information
Michael Higgins committed Apr 15, 2014
1 parent af6f838 commit 249682c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
1 change: 1 addition & 0 deletions autoProcess.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 5 additions & 2 deletions mkvtomp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions readSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit 249682c

Please sign in to comment.