mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-31 03:50:06 -07:00
We now can post-process files not inside of there own folder, we simply confirm there at the root of our category or watch folder then move them into there own seperate foldersand go from there.
nzbName's are now cleaned up.
This commit is contained in:
parent
086eaaa516
commit
fd4d14be64
7 changed files with 175 additions and 88 deletions
|
@ -27,25 +27,11 @@ class Transcoder:
|
|||
ffmpeg = 'ffmpeg'
|
||||
useNiceness = True
|
||||
|
||||
mediaContainer = (nzbtomedia.CFG["Transcoder"]["duplicate"])
|
||||
duplicate = int(nzbtomedia.CFG["Transcoder"]["duplicate"])
|
||||
ignoreExtensions = (nzbtomedia.CFG["Transcoder"]["ignoreExtensions"])
|
||||
outputVideoExtension = nzbtomedia.CFG["Transcoder"]["outputVideoExtension"].strip()
|
||||
outputVideoCodec = nzbtomedia.CFG["Transcoder"]["outputVideoCodec"].strip()
|
||||
outputVideoPreset = nzbtomedia.CFG["Transcoder"]["outputVideoPreset"].strip()
|
||||
outputVideoFramerate = nzbtomedia.CFG["Transcoder"]["outputVideoFramerate"].strip()
|
||||
outputVideoBitrate = nzbtomedia.CFG["Transcoder"]["outputVideoBitrate"].strip()
|
||||
outputAudioCodec = nzbtomedia.CFG["Transcoder"]["outputAudioCodec"].strip()
|
||||
outputAudioBitrate = nzbtomedia.CFG["Transcoder"]["outputAudioBitrate"].strip()
|
||||
outputSubtitleCodec = nzbtomedia.CFG["Transcoder"]["outputSubtitleCodec"].strip()
|
||||
outputFastStart = int(nzbtomedia.CFG["Transcoder"]["outputFastStart"])
|
||||
outputQualityPercent = int(nzbtomedia.CFG["Transcoder"]["outputQualityPercent"])
|
||||
|
||||
niceness = None
|
||||
if useNiceness:niceness = int(nzbtomedia.CFG["Transcoder"]["niceness"])
|
||||
if useNiceness:niceness = nzbtomedia.NICENESS
|
||||
|
||||
map(lambda ext: ext.strip(), mediaContainer)
|
||||
map(lambda ext: ext.strip(), ignoreExtensions)
|
||||
map(lambda ext: ext.strip(), nzbtomedia.MEDIACONTAINER)
|
||||
map(lambda ext: ext.strip(), nzbtomedia.IGNOREEXTENSIONS)
|
||||
|
||||
logger.info("Checking for files to be transcoded")
|
||||
final_result = 0 # initialize as successful
|
||||
|
@ -53,8 +39,8 @@ class Transcoder:
|
|||
for file in filenames:
|
||||
filePath = os.path.join(dirpath, file)
|
||||
name, ext = os.path.splitext(filePath)
|
||||
if ext in mediaContainer: # If the file is a video file
|
||||
if ext in ignoreExtensions:
|
||||
if ext in nzbtomedia.MEDIACONTAINER: # If the file is a video file
|
||||
if ext in nzbtomedia.IGNOREEXTENSIONS:
|
||||
logger.info("No need to transcode video type %s", ext)
|
||||
continue
|
||||
if ext == outputVideoExtension: # we need to change the name to prevent overwriting itself.
|
||||
|
@ -66,42 +52,42 @@ class Transcoder:
|
|||
if useNiceness:
|
||||
command = ['nice', '-%d' % niceness] + command
|
||||
|
||||
if len(outputVideoCodec) > 0:
|
||||
if len(nzbtomedia.OUTPUTVIDEOCODEC) > 0:
|
||||
command.append('-c:v')
|
||||
command.append(outputVideoCodec)
|
||||
if outputVideoCodec == 'libx264' and outputVideoPreset:
|
||||
command.append(nzbtomedia.OUTPUTVIDEOCODEC)
|
||||
if nzbtomedia.OUTPUTVIDEOCODEC == 'libx264' and nzbtomedia.OUTPUTVIDEOPRESET:
|
||||
command.append('-preset')
|
||||
command.append(outputVideoPreset)
|
||||
command.append(nzbtomedia.OUTPUTVIDEOPRESET)
|
||||
else:
|
||||
command.append('-c:v')
|
||||
command.append('copy')
|
||||
if len(outputVideoFramerate) > 0:
|
||||
if len(nzbtomedia.OUTPUTVIDEOFRAMERATE) > 0:
|
||||
command.append('-r')
|
||||
command.append(str(outputVideoFramerate))
|
||||
if len(outputVideoBitrate) > 0:
|
||||
command.append(str(nzbtomedia.OUTPUTVIDEOFRAMERATE))
|
||||
if len(nzbtomedia.OUTPUTVIDEOBITRATE) > 0:
|
||||
command.append('-b:v')
|
||||
command.append(str(outputVideoBitrate))
|
||||
if len(outputAudioCodec) > 0:
|
||||
command.append(str(nzbtomedia.OUTPUTVIDEOBITRATE))
|
||||
if len(nzbtomedia.OUTPUTAUDIOCODEC) > 0:
|
||||
command.append('-c:a')
|
||||
command.append(outputAudioCodec)
|
||||
if outputAudioCodec == 'aac': # Allow users to use the experimental AAC codec that's built into recent versions of ffmpeg
|
||||
command.append(nzbtomedia.OUTPUTAUDIOCODEC)
|
||||
if nzbtomedia.OUTPUTAUDIOCODEC == 'aac': # Allow users to use the experimental AAC codec that's built into recent versions of ffmpeg
|
||||
command.append('-strict')
|
||||
command.append('-2')
|
||||
else:
|
||||
command.append('-c:a')
|
||||
command.append('copy')
|
||||
if len(outputAudioBitrate) > 0:
|
||||
if len(nzbtomedia.OUTPUTAUDIOBITRATE) > 0:
|
||||
command.append('-b:a')
|
||||
command.append(str(outputAudioBitrate))
|
||||
if outputFastStart > 0:
|
||||
command.append(str(nzbtomedia.OUTPUTAUDIOBITRATE))
|
||||
if nzbtomedia.OUTPUTFASTSTART > 0:
|
||||
command.append('-movflags')
|
||||
command.append('+faststart')
|
||||
if outputQualityPercent > 0:
|
||||
if nzbtomedia.OUTPUTQUALITYPERCENT > 0:
|
||||
command.append('-q:a')
|
||||
command.append(str(outputQualityPercent))
|
||||
if len(outputSubtitleCodec) > 0: # Not every subtitle codec can be used for every video container format!
|
||||
command.append(str(nzbtomedia.OUTPUTQUALITYPERCENT))
|
||||
if len(nzbtomedia.OUTPUTSUBTITLECODEC) > 0: # Not every subtitle codec can be used for every video container format!
|
||||
command.append('-c:s')
|
||||
command.append(outputSubtitleCodec) # http://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/subtitle_options
|
||||
command.append(nzbtomedia.OUTPUTSUBTITLECODEC) # http://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/subtitle_options
|
||||
else:
|
||||
command.append('-sn') # Don't copy the subtitles over
|
||||
command.append(newfilePath)
|
||||
|
@ -126,7 +112,7 @@ class Transcoder:
|
|||
logger.error("Transcoding of video %s has failed", filePath)
|
||||
if result == 0:
|
||||
logger.info("Transcoding of video %s to %s succeeded", filePath, newfilePath)
|
||||
if duplicate == 0: # we get rid of the original file
|
||||
if nzbtomedia.DUPLICATE == 0: # we get rid of the original file
|
||||
os.unlink(filePath)
|
||||
else:
|
||||
logger.error("Transcoding of video %s to %s failed", filePath, newfilePath)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue