diff --git a/src/ffx/ffx.py b/src/ffx/ffx.py index 04c69f4..7a6ec36 100755 --- a/src/ffx/ffx.py +++ b/src/ffx/ffx.py @@ -426,7 +426,7 @@ def convert(ctx, or if the filename has not changed.""" startTime = time.perf_counter() - + context = ctx.obj context['video_encoder'] = VideoEncoder.fromLabel(video_encoder) @@ -633,6 +633,16 @@ def convert(ctx, 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 currentPattern = mediaFileProperties.getPattern() if context['use_pattern'] else None diff --git a/src/ffx/media_descriptor.py b/src/ffx/media_descriptor.py index 6b4d0ee..65cbd0f 100644 --- a/src/ffx/media_descriptor.py +++ b/src/ffx/media_descriptor.py @@ -320,6 +320,13 @@ class MediaDescriptor: 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): """Generate ffmpeg import options for external stream files""" @@ -366,12 +373,14 @@ class MediaDescriptor: stdsi = sortedTrackDescriptors[td.getSourceIndex()].getSubIndex() trackType = td.getType() + trackCodec = td.getCodec() if (trackType == TrackType.VIDEO or not only_video): + importedFilePath = td.getExternalSourceFilePath() - if use_sub_index: + if use_sub_index and not (trackType == TrackType.ATTACHMENT and trackCodec == TrackCodec.TTF): if importedFilePath: @@ -383,16 +392,17 @@ class MediaDescriptor: else: - if not td.getCodec() in [TrackCodec.PGS, TrackCodec.VOBSUB]: + if not trackCodec in [TrackCodec.PGS, TrackCodec.VOBSUB]: inputMappingTokens += [ "-map", f"0:{trackType.indicator()}:{stdsi}", ] else: - if not td.getCodec() in [TrackCodec.PGS, TrackCodec.VOBSUB]: + if not trackCodec in [TrackCodec.PGS, TrackCodec.VOBSUB]: inputMappingTokens += ["-map", f"0:{stdi}"] + return inputMappingTokens diff --git a/src/ffx/track_codec.py b/src/ffx/track_codec.py index dfd415b..f560715 100644 --- a/src/ffx/track_codec.py +++ b/src/ffx/track_codec.py @@ -16,6 +16,7 @@ class TrackCodec(Enum): SRT = {'identifier': 'subrip', 'format': 'srt', 'extension': 'srt' , 'label': 'SRT'} 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'} VOBSUB = {'identifier': 'dvd_subtitle', 'format': None, 'extension': 'mkv' , 'label': 'VobSub'} diff --git a/src/ffx/track_type.py b/src/ffx/track_type.py index 6775325..5c8a7f0 100644 --- a/src/ffx/track_type.py +++ b/src/ffx/track_type.py @@ -5,6 +5,7 @@ class TrackType(Enum): VIDEO = {'label': 'video', 'index': 1} AUDIO = {'label': 'audio', 'index': 2} SUBTITLE = {'label': 'subtitle', 'index': 3} + ATTACHMENT = {'label': 'attachment', 'index': 4} UNKNOWN = {'label': 'unknown', 'index': 0}