|
|
|
@ -4,6 +4,7 @@ from ffx.media_descriptor import MediaDescriptor
|
|
|
|
|
from ffx.helper import DIFF_ADDED_KEY, DIFF_REMOVED_KEY, DIFF_CHANGED_KEY
|
|
|
|
|
from ffx.track_descriptor import TrackDescriptor
|
|
|
|
|
from ffx.model.track import Track
|
|
|
|
|
from ffx.audio_layout import AudioLayout
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FfxController():
|
|
|
|
@ -37,8 +38,12 @@ class FfxController():
|
|
|
|
|
|
|
|
|
|
INPUT_FILE_EXTENSIONS = ['mkv', 'mp4', 'avi', 'flv', 'webm']
|
|
|
|
|
|
|
|
|
|
def __init__(self, sourceMediaDescriptor : MediaDescriptor, targetMediaDescriptor : MediaDescriptor):
|
|
|
|
|
def __init__(self,
|
|
|
|
|
context : dict,
|
|
|
|
|
sourceMediaDescriptor : MediaDescriptor,
|
|
|
|
|
targetMediaDescriptor : MediaDescriptor):
|
|
|
|
|
|
|
|
|
|
self.__context = context
|
|
|
|
|
self.__sourceMediaDescriptor = sourceMediaDescriptor
|
|
|
|
|
self.__targetMediaDescriptor = targetMediaDescriptor
|
|
|
|
|
|
|
|
|
@ -99,49 +104,49 @@ class FfxController():
|
|
|
|
|
return ['-f', format, f"{filepath}.{ext}"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generateAudioEncodingTokens(self, context, index, layout):
|
|
|
|
|
def generateAudioEncodingTokens(self, subIndex : int, layout : AudioLayout):
|
|
|
|
|
"""Generates ffmpeg options for one output audio stream including channel remapping, codec and bitrate"""
|
|
|
|
|
pass
|
|
|
|
|
#
|
|
|
|
|
# if layout == STREAM_LAYOUT_6_1:
|
|
|
|
|
# return [f"-c:a:{index}",
|
|
|
|
|
# 'libopus',
|
|
|
|
|
# f"-filter:a:{index}",
|
|
|
|
|
# 'channelmap=channel_layout=6.1',
|
|
|
|
|
# f"-b:a:{index}",
|
|
|
|
|
# context['bitrates']['dts']]
|
|
|
|
|
#
|
|
|
|
|
# elif layout == STREAM_LAYOUT_5_1:
|
|
|
|
|
# return [f"-c:a:{index}",
|
|
|
|
|
# 'libopus',
|
|
|
|
|
# f"-filter:a:{index}",
|
|
|
|
|
# "channelmap=FL-FL|FR-FR|FC-FC|LFE-LFE|SL-BL|SR-BR:5.1",
|
|
|
|
|
# f"-b:a:{index}",
|
|
|
|
|
# context['bitrates']['ac3']]
|
|
|
|
|
#
|
|
|
|
|
# elif layout == STREAM_LAYOUT_STEREO:
|
|
|
|
|
# return [f"-c:a:{index}",
|
|
|
|
|
# 'libopus',
|
|
|
|
|
# f"-b:a:{index}",
|
|
|
|
|
# context['bitrates']['stereo']]
|
|
|
|
|
#
|
|
|
|
|
# elif layout == STREAM_LAYOUT_6CH:
|
|
|
|
|
# return [f"-c:a:{index}",
|
|
|
|
|
# 'libopus',
|
|
|
|
|
# f"-filter:a:{index}",
|
|
|
|
|
# "channelmap=FL-FL|FR-FR|FC-FC|LFE-LFE|SL-BL|SR-BR:5.1",
|
|
|
|
|
# f"-b:a:{index}",
|
|
|
|
|
# context['bitrates']['ac3']]
|
|
|
|
|
# else:
|
|
|
|
|
# return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generateClearTokens(self, streams):
|
|
|
|
|
clearTokens = []
|
|
|
|
|
for s in streams:
|
|
|
|
|
for k in FfxController.MKVMERGE_METADATA_KEYS:
|
|
|
|
|
clearTokens += [f"-metadata:s:{s['type'][0]}:{s['sub_index']}", f"{k}="]
|
|
|
|
|
return clearTokens
|
|
|
|
|
|
|
|
|
|
if layout == AudioLayout.LAYOUT_6_1:
|
|
|
|
|
return [f"-c:a:{subIndex}",
|
|
|
|
|
'libopus',
|
|
|
|
|
f"-filter:a:{subIndex}",
|
|
|
|
|
'channelmap=channel_layout=6.1',
|
|
|
|
|
f"-b:a:{subIndex}",
|
|
|
|
|
self.__context['bitrates']['dts']]
|
|
|
|
|
|
|
|
|
|
elif layout == AudioLayout.LAYOUT_5_1:
|
|
|
|
|
return [f"-c:a:{subIndex}",
|
|
|
|
|
'libopus',
|
|
|
|
|
f"-filter:a:{subIndex}",
|
|
|
|
|
"channelmap=FL-FL|FR-FR|FC-FC|LFE-LFE|SL-BL|SR-BR:5.1",
|
|
|
|
|
f"-b:a:{subIndex}",
|
|
|
|
|
self.__context['bitrates']['ac3']]
|
|
|
|
|
|
|
|
|
|
elif layout == AudioLayout.LAYOUT_STEREO:
|
|
|
|
|
return [f"-c:a:{subIndex}",
|
|
|
|
|
'libopus',
|
|
|
|
|
f"-b:a:{subIndex}",
|
|
|
|
|
self.__context['bitrates']['stereo']]
|
|
|
|
|
|
|
|
|
|
elif layout == AudioLayout.LAYOUT_6CH:
|
|
|
|
|
return [f"-c:a:{subIndex}",
|
|
|
|
|
'libopus',
|
|
|
|
|
f"-filter:a:{subIndex}",
|
|
|
|
|
"channelmap=FL-FL|FR-FR|FC-FC|LFE-LFE|SL-BL|SR-BR:5.1",
|
|
|
|
|
f"-b:a:{subIndex}",
|
|
|
|
|
self.__context['bitrates']['ac3']]
|
|
|
|
|
else:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def generateClearTokens(self, streams):
|
|
|
|
|
# clearTokens = []
|
|
|
|
|
# for s in streams:
|
|
|
|
|
# for k in FfxController.MKVMERGE_METADATA_KEYS:
|
|
|
|
|
# clearTokens += [f"-metadata:s:{s['type'][0]}:{s['sub_index']}", f"{k}="]
|
|
|
|
|
# return clearTokens
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|