[downloader/ism] Support muxing TTML subtitles

This commit is contained in:
Felix S 2021-04-18 12:48:39 +02:00
parent 15828bcf25
commit 66a1b8643a
2 changed files with 10 additions and 3 deletions

View File

@ -118,8 +118,7 @@ def write_piff_header(stream, params):
vmhd_payload += u16.pack(0) * 3 # opcolor vmhd_payload += u16.pack(0) * 3 # opcolor
media_header_box = full_box(b'vmhd', 0, 1, vmhd_payload) # Video Media Header media_header_box = full_box(b'vmhd', 0, 1, vmhd_payload) # Video Media Header
elif stream_type == 'text': elif stream_type == 'text':
sthd_payload = u16.pack(0) * 2 media_header_box = full_box(b'sthd', 0, 0, b'') # Subtitle Media Header
media_header_box = full_box(b'sthd', 0, 1, sthd_payload) # Subtitle Media Header
else: else:
assert False assert False
minf_payload = media_header_box minf_payload = media_header_box
@ -173,6 +172,14 @@ def write_piff_header(stream, params):
sample_entry_box = box(b'avc1', sample_entry_payload) # AVC Simple Entry sample_entry_box = box(b'avc1', sample_entry_payload) # AVC Simple Entry
else: else:
assert False assert False
elif stream_type == 'text':
if fourcc == 'TTML':
sample_entry_payload += b'http://www.w3.org/ns/ttml\0' # namespace
sample_entry_payload += b'\0' # schema location
sample_entry_payload += b'\0' # auxilary mime types(??)
sample_entry_box = box(b'stpp', sample_entry_payload)
else:
assert False
else: else:
assert False assert False
stsd_payload += sample_entry_box stsd_payload += sample_entry_box

View File

@ -2816,7 +2816,7 @@ def _parse_ism_formats_and_subtitles(self, ism_doc, ism_url, ism_id=None):
for track in stream.findall('QualityLevel'): for track in stream.findall('QualityLevel'):
fourcc = track.get('FourCC', 'AACL' if track.get('AudioTag') == '255' else None) fourcc = track.get('FourCC', 'AACL' if track.get('AudioTag') == '255' else None)
# TODO: add support for WVC1 and WMAP # TODO: add support for WVC1 and WMAP
if fourcc not in ('H264', 'AVC1', 'AACL'): if fourcc not in ('H264', 'AVC1', 'AACL', 'TTML'):
self.report_warning('%s is not a supported codec' % fourcc) self.report_warning('%s is not a supported codec' % fourcc)
continue continue
tbr = int(track.attrib['Bitrate']) // 1000 tbr = int(track.attrib['Bitrate']) // 1000