|
|
|
@ -20,6 +20,7 @@ class MediaDescriptor:
|
|
|
|
TRACKS_KEY = "tracks"
|
|
|
|
TRACKS_KEY = "tracks"
|
|
|
|
|
|
|
|
|
|
|
|
TRACK_DESCRIPTOR_LIST_KEY = "track_descriptors"
|
|
|
|
TRACK_DESCRIPTOR_LIST_KEY = "track_descriptors"
|
|
|
|
|
|
|
|
ATTACHMENT_DESCRIPTOR_LIST_KEY = "attachment_descriptors"
|
|
|
|
CLEAR_TAGS_FLAG_KEY = "clear_tags"
|
|
|
|
CLEAR_TAGS_FLAG_KEY = "clear_tags"
|
|
|
|
|
|
|
|
|
|
|
|
FFPROBE_DISPOSITION_KEY = "disposition"
|
|
|
|
FFPROBE_DISPOSITION_KEY = "disposition"
|
|
|
|
@ -69,9 +70,9 @@ class MediaDescriptor:
|
|
|
|
raise TypeError(
|
|
|
|
raise TypeError(
|
|
|
|
f"TrackDesciptor.__init__(): All elements of argument list {MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY} are required to be of type TrackDescriptor"
|
|
|
|
f"TrackDesciptor.__init__(): All elements of argument list {MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY} are required to be of type TrackDescriptor"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
self.__trackDescriptors = kwargs[MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY]
|
|
|
|
self.__trackDescriptors: List[TrackDescriptor] = kwargs[MediaDescriptor.TRACK_DESCRIPTOR_LIST_KEY]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.__trackDescriptors = []
|
|
|
|
self.__trackDescriptors: List[TrackDescriptor] = []
|
|
|
|
|
|
|
|
|
|
|
|
def setTrackLanguage(self, language: str, index: int, trackType: TrackType = None):
|
|
|
|
def setTrackLanguage(self, language: str, index: int, trackType: TrackType = None):
|
|
|
|
|
|
|
|
|
|
|
|
@ -352,7 +353,10 @@ class MediaDescriptor:
|
|
|
|
return importFileTokens
|
|
|
|
return importFileTokens
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getInputMappingTokens(self, use_sub_index: bool = True, only_video: bool = False):
|
|
|
|
def getInputMappingTokens(self,
|
|
|
|
|
|
|
|
use_sub_index: bool = True,
|
|
|
|
|
|
|
|
only_video: bool = False,
|
|
|
|
|
|
|
|
sourceMediaDescriptor: Self = None):
|
|
|
|
"""Tracks must be reordered for source index order"""
|
|
|
|
"""Tracks must be reordered for source index order"""
|
|
|
|
|
|
|
|
|
|
|
|
inputMappingTokens = []
|
|
|
|
inputMappingTokens = []
|
|
|
|
@ -375,12 +379,13 @@ class MediaDescriptor:
|
|
|
|
trackType = td.getType()
|
|
|
|
trackType = td.getType()
|
|
|
|
trackCodec = td.getCodec()
|
|
|
|
trackCodec = td.getCodec()
|
|
|
|
|
|
|
|
|
|
|
|
if (trackType == TrackType.VIDEO or not only_video):
|
|
|
|
if (trackType != TrackType.ATTACHMENT
|
|
|
|
|
|
|
|
and (trackType == TrackType.VIDEO or not only_video)):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
importedFilePath = td.getExternalSourceFilePath()
|
|
|
|
importedFilePath = td.getExternalSourceFilePath()
|
|
|
|
|
|
|
|
|
|
|
|
if use_sub_index and not (trackType == TrackType.ATTACHMENT and trackCodec == TrackCodec.TTF):
|
|
|
|
if use_sub_index:
|
|
|
|
|
|
|
|
|
|
|
|
if importedFilePath:
|
|
|
|
if importedFilePath:
|
|
|
|
|
|
|
|
|
|
|
|
@ -402,6 +407,16 @@ class MediaDescriptor:
|
|
|
|
if not trackCodec in [TrackCodec.PGS, TrackCodec.VOBSUB]:
|
|
|
|
if not trackCodec in [TrackCodec.PGS, TrackCodec.VOBSUB]:
|
|
|
|
inputMappingTokens += ["-map", f"0:{stdi}"]
|
|
|
|
inputMappingTokens += ["-map", f"0:{stdi}"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sourceMediaDescriptor:
|
|
|
|
|
|
|
|
fontDescriptors = [ftd for ftd in sourceMediaDescriptor.getAttachmentTracks()
|
|
|
|
|
|
|
|
if ftd.getCodec() == TrackCodec.TTF]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
fontDescriptors = [ftd for ftd in self.__trackDescriptors
|
|
|
|
|
|
|
|
if ftd.getType() == TrackType.ATTACHMENT
|
|
|
|
|
|
|
|
and ftd.getCodec() == TrackCodec.TTF]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ad in sorted(fontDescriptors, key=lambda d: d.getIndex()):
|
|
|
|
|
|
|
|
inputMappingTokens += ["-map", f"0:{ad.getIndex()}"]
|
|
|
|
|
|
|
|
|
|
|
|
return inputMappingTokens
|
|
|
|
return inputMappingTokens
|
|
|
|
|
|
|
|
|
|
|
|
|