diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index f7cd0b85..f59e1cf6 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -255,6 +255,8 @@ transcode = 0 ###### duplicate =1 will cretae a new file. =0 will replace the original duplicate = 1 + # concat. joins cd1 cd2 etc into a single video. + concat = 1 ignoreExtensions = .avi,.mkv,.mp4 # outputFastStart. 1 will use -movflags + faststart. 0 will disable this from being used. outputFastStart = 0 diff --git a/nzbtomedia/__init__.py b/nzbtomedia/__init__.py index b74d507c..ec8d0dbe 100644 --- a/nzbtomedia/__init__.py +++ b/nzbtomedia/__init__.py @@ -127,6 +127,7 @@ CATEGORIES = [] GETSUBS = False TRANSCODE = None +CONCAT = None FFMPEG_PATH = None DUPLICATE = None IGNOREEXTENSIONS = [] @@ -193,7 +194,7 @@ def initialize(section=None): SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ NOFLATTEN, UTORRENTPWD, UTORRENTUSR, UTORRENTWEBUI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, \ TRANSMISSIONHOST, TRANSMISSIONPORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \ - METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, \ + METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \ DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ @@ -378,6 +379,7 @@ def initialize(section=None): GETSUBS = int(CFG["Transcoder"]["getSubs"]) TRANSCODE = int(CFG["Transcoder"]["transcode"]) DUPLICATE = int(CFG["Transcoder"]["duplicate"]) + CONCAT = int(CFG["Transcoder"]["concat"]) IGNOREEXTENSIONS = (CFG["Transcoder"]["ignoreExtensions"]) if isinstance(IGNOREEXTENSIONS, str): IGNOREEXTENSIONS = IGNOREEXTENSIONS.split(',') OUTPUTFASTSTART = int(CFG["Transcoder"]["outputFastStart"]) diff --git a/nzbtomedia/transcoder/transcoder.py b/nzbtomedia/transcoder/transcoder.py index 0b733b8d..c8ef52a1 100644 --- a/nzbtomedia/transcoder/transcoder.py +++ b/nzbtomedia/transcoder/transcoder.py @@ -500,6 +500,7 @@ def processList(List, newDir, bitbucket): remList = [] newList = [] delList = [] + combine = [] vtsPath = None success = True for item in List: @@ -519,9 +520,14 @@ def processList(List, newDir, bitbucket): remList.append(item) elif re.match(".+VIDEO_TS.", item) or re.match(".+VTS_[0-9][0-9]_[0-9].", item): remList.append(item) + elif nzbtomedia.CONCAT and re.match(".+[cC][dD][0-9].", item): + remList.append(item) + combine.append(item) else: continue if vtsPath: newList.extend(combineVTS(vtsPath)) + if combine: + newList.extend(combineCD(combine)) for file in newList: if isinstance(file, str) and not 'concat:' in file and not os.path.isfile(file): success = False @@ -553,6 +559,7 @@ def ripISO(item, newDir, bitbucket): out, err = proc.communicate() result = proc.returncode fileList = [ re.match(".+(VIDEO_TS[\\\/]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb])", line).groups()[0] for line in out.splitlines() if re.match(".+VIDEO_TS[\\\/]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]", line) ] + combined = [] for n in range(99): concat = [] m = 1 @@ -565,9 +572,14 @@ def ripISO(item, newDir, bitbucket): break if not concat: break + if nzbtomedia.CONCAT: + combined.extend(concat) + continue name = '%s.cd%s' % (os.path.splitext(os.path.split(item)[1])[0] ,str(n+1)) newFiles.append({item: {'name': name , 'files': concat}}) - + if nzbtomedia.CONCAT: + name = os.path.splitext(os.path.split(item)[1])[0] + newFiles.append({item: {'name': name , 'files': combined}}) if not newFiles: logger.error("No VIDEO_TS folder found in image file %s" % (item), "TRANSCODER") newFiles = [failure_dir] @@ -578,6 +590,7 @@ def ripISO(item, newDir, bitbucket): def combineVTS(vtsPath): newFiles = [] + combined = '' for n in range(99): concat = '' m = 1 @@ -590,7 +603,26 @@ def combineVTS(vtsPath): break if not concat: break + if nzbtomedia.CONCAT: + combined = combined + concat + '|' + continue newFiles.append('concat:%s' % concat[:-1]) + if nzbtomedia.CONCAT: + newFiles.append('concat:%s' % combined[:-1]) + return newFiles + +def combineCD(combine): + newFiles = [] + for item in set([ re.match("(.+)[cC][dD][0-9].",item).groups()[0] for item in combine ]): + concat = '' + for n in range(99): + files = [ file for file in combine if n+1 == int(re.match(".+[cC][dD]([0-9]).",file).groups()[0]) and item in file ] + if files: + concat = concat + files[0] + '|' + else: + break + if concat: + newFiles.append('concat:%s' % concat[:-1]) return newFiles def print_cmd(command):