tf h264/mkv
This commit is contained in:
@@ -305,9 +305,9 @@ def checkUniqueDispositions(context, mediaDescriptor: MediaDescriptor):
|
||||
|
||||
@click.option('-l', '--label', type=str, default='', help='Label to be used as filename prefix')
|
||||
|
||||
@click.option('-v', '--video-encoder', type=str, default=FfxController.DEFAULT_VIDEO_ENCODER, help=f"Target video encoder (vp9 or av1)", show_default=True)
|
||||
@click.option('-v', '--video-encoder', type=str, default=FfxController.DEFAULT_VIDEO_ENCODER, help=f"Target video encoder (vp9, av1 or h264)", show_default=True)
|
||||
|
||||
@click.option('-q', '--quality', type=str, default="", help=f"Quality settings to be used with VP9 encoder")
|
||||
@click.option('-q', '--quality', type=str, default="", help=f"Quality settings to be used with VP9/H264 encoder")
|
||||
@click.option('-p', '--preset', type=str, default="", help=f"Quality preset to be used with AV1 encoder")
|
||||
|
||||
@click.option('-a', '--stereo-bitrate', type=int, default=DEFAULT_STEREO_BANDWIDTH, help=f"Bitrate in kbit/s to be used to encode stereo audio streams", show_default=True)
|
||||
|
||||
@@ -55,6 +55,14 @@ class FfxController():
|
||||
'-pix_fmt', 'yuv420p10le']
|
||||
|
||||
|
||||
# -c:v libx264 -preset slow -crf 17
|
||||
def generateH264Tokens(self, quality, subIndex : int = 0):
|
||||
|
||||
return [f"-c:v:{int(subIndex)}", 'libx264',
|
||||
"-preset", "slow"
|
||||
f"crf={quality}"]
|
||||
|
||||
|
||||
# -c:v:0 libvpx-vp9 -row-mt 1 -crf 32 -pass 1 -speed 4 -frame-parallel 0 -g 9999 -aq-mode 0
|
||||
def generateVP9Pass1Tokens(self, quality, subIndex : int = 0):
|
||||
|
||||
@@ -176,7 +184,9 @@ class FfxController():
|
||||
presetFilters = [fy for fy in chainIteration if fy['identifier'] == 'preset']
|
||||
denoiseFilters = [fy for fy in chainIteration if fy['identifier'] == 'nlmeans']
|
||||
|
||||
quality = qualityFilters[0]['parameters']['quality'] if qualityFilters else QualityFilter.DEFAULT_QUALITY
|
||||
quality = (qualityFilters[0]['parameters']['quality'] if qualityFilters
|
||||
else QualityFilter.DEFAULT_H264_QUALITY if videoEncoder == VideoEncoder.H264
|
||||
else QualityFilter.DEFAULT_VP9_QUALITY)
|
||||
preset = presetFilters[0]['parameters']['preset'] if presetFilters else PresetFilter.DEFAULT_PRESET
|
||||
|
||||
|
||||
@@ -215,6 +225,37 @@ class FfxController():
|
||||
executeProcess(commandSequence, context = self.__context)
|
||||
|
||||
|
||||
if videoEncoder == VideoEncoder.H264:
|
||||
|
||||
commandSequence = (commandTokens
|
||||
+ self.__targetMediaDescriptor.getImportFileTokens()
|
||||
+ self.__targetMediaDescriptor.getInputMappingTokens()
|
||||
+ self.__mdcs.generateDispositionTokens())
|
||||
|
||||
# Optional tokens
|
||||
commandSequence += self.__mdcs.generateMetadataTokens()
|
||||
commandSequence += denoiseTokens
|
||||
|
||||
for td in self.__targetMediaDescriptor.getTrackDescriptors(trackType=TrackType.VIDEO):
|
||||
#HINT: Attached thumbnails are not supported by .webm container format
|
||||
if td.getCodec != TrackCodec.PNG:
|
||||
commandSequence += self.generateH264Tokens(int(quality))
|
||||
|
||||
commandSequence += self.generateAudioEncodingTokens()
|
||||
|
||||
if self.__context['perform_crop']:
|
||||
commandSequence += FfxController.generateCropTokens()
|
||||
|
||||
commandSequence += self.generateOutputTokens(targetPath,
|
||||
'mkv')
|
||||
|
||||
self.__logger.debug(f"FfxController.runJob(): Running command sequence")
|
||||
|
||||
if not self.__context['dry_run']:
|
||||
executeProcess(commandSequence, context = self.__context)
|
||||
|
||||
|
||||
|
||||
if videoEncoder == VideoEncoder.VP9:
|
||||
|
||||
commandSequence1 = (commandTokens
|
||||
|
||||
@@ -7,7 +7,8 @@ class QualityFilter(Filter):
|
||||
|
||||
IDENTIFIER = 'quality'
|
||||
|
||||
DEFAULT_QUALITY = 32
|
||||
DEFAULT_VP9_QUALITY = 32
|
||||
DEFAULT_H264_QUALITY = 17
|
||||
|
||||
QUALITY_KEY = 'quality'
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ class VideoEncoder(Enum):
|
||||
|
||||
AV1 = {'label': 'av1', 'index': 1}
|
||||
VP9 = {'label': 'vp9', 'index': 2}
|
||||
H264 = {'label': 'h264', 'index': 3}
|
||||
|
||||
UNDEFINED = {'label': 'undefined', 'index': 0}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user