From 01dd0d8aa29cbca4bfba5495fc06d5d746618559 Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 20 Mar 2016 02:31:09 -0400 Subject: [PATCH] subtitle-encoding option --- autoProcess.ini.sample | 2 ++ converter/avcodecs.py | 8 ++++++-- mkvtomp4.py | 5 ++++- readSettings.py | 5 +++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/autoProcess.ini.sample b/autoProcess.ini.sample index 990b46af..289029df 100644 --- a/autoProcess.ini.sample +++ b/autoProcess.ini.sample @@ -17,6 +17,7 @@ apikey = [MP4] ffmpeg = ffmpeg.exe ffprobe = ffprobe.exe +threads = auto output_directory = copy_to = move_to = @@ -38,6 +39,7 @@ audio-channel-bitrate = subtitle-codec = mov_text subtitle-language = subtitle-default-language = +subtitle-encoding = utf-8 fullpathguess = True convert-mp4 = False tagfile = True diff --git a/converter/avcodecs.py b/converter/avcodecs.py index 72a597ef..6b51e377 100644 --- a/converter/avcodecs.py +++ b/converter/avcodecs.py @@ -169,15 +169,19 @@ def parse_options(self, opt, stream=0): else: s = str(0) + if 'encoding' in safe: + if safe['encoding'] is None: + del safe['encoding'] + safe = self._codec_specific_parse_options(safe) optlist = [] + if 'encoding' in safe: + optlist.extend(['-sub_charenc', str(safe['encoding'])]) optlist.extend(['-c:s:' + stream, self.ffmpeg_codec_name]) stream = str(stream) if 'map' in safe: optlist.extend(['-map', s + ':' + str(safe['map'])]) - if 'encoding' in safe: - optlist.extend(['-sub_charenc', str(safe['encoding'])]) if 'path' in safe: optlist.extend(['-i', str(safe['path'])]) if 'default' in safe: diff --git a/mkvtomp4.py b/mkvtomp4.py index 17e1bf8d..9075d177 100644 --- a/mkvtomp4.py +++ b/mkvtomp4.py @@ -33,6 +33,7 @@ def __init__(self, settings=None, adl=None, sdl=None, scodec='mov_text', + subencoding='utf-8', downloadsubs=True, processMP4=False, copyto=None, @@ -84,6 +85,7 @@ def __init__(self, settings=None, self.downloadsubs = downloadsubs self.subproviders = providers self.embedsubs = embedsubs + self.subencoding = subencoding # Import settings if settings is not None: @@ -126,6 +128,7 @@ def importSettings(self, settings): self.downloadsubs = settings.downloadsubs self.subproviders = settings.subproviders self.embedsubs = settings.embedsubs + self.subencoding = settings.subencoding self.log.debug("Settings imported.") @@ -419,7 +422,7 @@ def generateOptions(self, inputfile, original=None): 'map': s.index, 'codec': self.scodec, 'language': s.metadata['language'], - 'encoding': 'UTF-8' + 'encoding': self.subencoding, # 'forced': s.sub_forced, # 'default': s.sub_default }}) diff --git a/readSettings.py b/readSettings.py index 5cb8dc51..9f09bdd3 100644 --- a/readSettings.py +++ b/readSettings.py @@ -78,6 +78,7 @@ def __init__(self, directory, filename, logger=None): 'subtitle-codec': 'mov_text', 'subtitle-language': '', 'subtitle-default-language': '', + 'subtitle-encoding': 'utf-8', 'convert-mp4': 'False', 'fullpathguess': 'True', 'tagfile': 'True', @@ -367,6 +368,10 @@ def __init__(self, directory, filename, logger=None): else: self.swl = self.swl.replace(' ', '').split(',') + self.subencoding = config.get(section, 'subtitle-encoding').strip().lower() + if self.subencoding == '': + self.subencoding = None + self.adl = config.get(section, 'audio-default-language').strip().lower() # What language to default an undefinied audio language tag to. If blank, it will remain undefined. This is useful for single language releases which tend to leave things tagged as und if self.adl == "" or len(self.adl) > 3: self.adl = None