Adapt for .ssa subtitles with attached fonts
This commit is contained in:
@@ -426,7 +426,7 @@ def convert(ctx,
|
|||||||
or if the filename has not changed."""
|
or if the filename has not changed."""
|
||||||
|
|
||||||
startTime = time.perf_counter()
|
startTime = time.perf_counter()
|
||||||
|
|
||||||
context = ctx.obj
|
context = ctx.obj
|
||||||
|
|
||||||
context['video_encoder'] = VideoEncoder.fromLabel(video_encoder)
|
context['video_encoder'] = VideoEncoder.fromLabel(video_encoder)
|
||||||
@@ -633,6 +633,16 @@ def convert(ctx,
|
|||||||
|
|
||||||
sourceMediaDescriptor = mediaFileProperties.getMediaDescriptor()
|
sourceMediaDescriptor = mediaFileProperties.getMediaDescriptor()
|
||||||
|
|
||||||
|
|
||||||
|
if ([smd for smd in sourceMediaDescriptor.getSubtitleTracks()
|
||||||
|
if smd.getCodec() == TrackCodec.ASS]
|
||||||
|
and [amd for amd in sourceMediaDescriptor.getAttachmentTracks()
|
||||||
|
if amd.getCodec() == TrackCodec.TTF]):
|
||||||
|
|
||||||
|
targetFormat = ''
|
||||||
|
targetExtension = 'mkv'
|
||||||
|
|
||||||
|
|
||||||
#HINT: This is None if the filename did not match anything in database
|
#HINT: This is None if the filename did not match anything in database
|
||||||
currentPattern = mediaFileProperties.getPattern() if context['use_pattern'] else None
|
currentPattern = mediaFileProperties.getPattern() if context['use_pattern'] else None
|
||||||
|
|
||||||
|
|||||||
@@ -320,6 +320,13 @@ class MediaDescriptor:
|
|||||||
if s.getType() == TrackType.SUBTITLE
|
if s.getType() == TrackType.SUBTITLE
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def getAttachmentTracks(self) -> List[TrackDescriptor]:
|
||||||
|
return [
|
||||||
|
s
|
||||||
|
for s in self.__trackDescriptors
|
||||||
|
if s.getType() == TrackType.ATTACHMENT
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def getImportFileTokens(self, use_sub_index: bool = True):
|
def getImportFileTokens(self, use_sub_index: bool = True):
|
||||||
"""Generate ffmpeg import options for external stream files"""
|
"""Generate ffmpeg import options for external stream files"""
|
||||||
@@ -366,12 +373,14 @@ class MediaDescriptor:
|
|||||||
stdsi = sortedTrackDescriptors[td.getSourceIndex()].getSubIndex()
|
stdsi = sortedTrackDescriptors[td.getSourceIndex()].getSubIndex()
|
||||||
|
|
||||||
trackType = td.getType()
|
trackType = td.getType()
|
||||||
|
trackCodec = td.getCodec()
|
||||||
|
|
||||||
if (trackType == TrackType.VIDEO or not only_video):
|
if (trackType == TrackType.VIDEO or not only_video):
|
||||||
|
|
||||||
|
|
||||||
importedFilePath = td.getExternalSourceFilePath()
|
importedFilePath = td.getExternalSourceFilePath()
|
||||||
|
|
||||||
if use_sub_index:
|
if use_sub_index and not (trackType == TrackType.ATTACHMENT and trackCodec == TrackCodec.TTF):
|
||||||
|
|
||||||
if importedFilePath:
|
if importedFilePath:
|
||||||
|
|
||||||
@@ -383,16 +392,17 @@ class MediaDescriptor:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if not td.getCodec() in [TrackCodec.PGS, TrackCodec.VOBSUB]:
|
if not trackCodec in [TrackCodec.PGS, TrackCodec.VOBSUB]:
|
||||||
inputMappingTokens += [
|
inputMappingTokens += [
|
||||||
"-map",
|
"-map",
|
||||||
f"0:{trackType.indicator()}:{stdsi}",
|
f"0:{trackType.indicator()}:{stdsi}",
|
||||||
]
|
]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not td.getCodec() in [TrackCodec.PGS, TrackCodec.VOBSUB]:
|
if not trackCodec in [TrackCodec.PGS, TrackCodec.VOBSUB]:
|
||||||
inputMappingTokens += ["-map", f"0:{stdi}"]
|
inputMappingTokens += ["-map", f"0:{stdi}"]
|
||||||
|
|
||||||
|
|
||||||
return inputMappingTokens
|
return inputMappingTokens
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class TrackCodec(Enum):
|
|||||||
|
|
||||||
SRT = {'identifier': 'subrip', 'format': 'srt', 'extension': 'srt' , 'label': 'SRT'}
|
SRT = {'identifier': 'subrip', 'format': 'srt', 'extension': 'srt' , 'label': 'SRT'}
|
||||||
ASS = {'identifier': 'ass', 'format': 'ass', 'extension': 'ass' , 'label': 'ASS'}
|
ASS = {'identifier': 'ass', 'format': 'ass', 'extension': 'ass' , 'label': 'ASS'}
|
||||||
|
TTF = {'identifier': 'ttf', 'format': None, 'extension': 'ttf' , 'label': 'TTF'}
|
||||||
PGS = {'identifier': 'hdmv_pgs_subtitle', 'format': 'sup', 'extension': 'sup' , 'label': 'PGS'}
|
PGS = {'identifier': 'hdmv_pgs_subtitle', 'format': 'sup', 'extension': 'sup' , 'label': 'PGS'}
|
||||||
VOBSUB = {'identifier': 'dvd_subtitle', 'format': None, 'extension': 'mkv' , 'label': 'VobSub'}
|
VOBSUB = {'identifier': 'dvd_subtitle', 'format': None, 'extension': 'mkv' , 'label': 'VobSub'}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class TrackType(Enum):
|
|||||||
VIDEO = {'label': 'video', 'index': 1}
|
VIDEO = {'label': 'video', 'index': 1}
|
||||||
AUDIO = {'label': 'audio', 'index': 2}
|
AUDIO = {'label': 'audio', 'index': 2}
|
||||||
SUBTITLE = {'label': 'subtitle', 'index': 3}
|
SUBTITLE = {'label': 'subtitle', 'index': 3}
|
||||||
|
ATTACHMENT = {'label': 'attachment', 'index': 4}
|
||||||
|
|
||||||
UNKNOWN = {'label': 'unknown', 'index': 0}
|
UNKNOWN = {'label': 'unknown', 'index': 0}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user