mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 06:10:12 +01:00
[pp/FFmpegMetadata] Use metadata stream specifier for info.json
The old stream index specifiers would indiscriminately select any JSON attachment, which made stuff like embedding live chat json data risky if not impossible. Also adds `-copy_unknown` as JSON data is "unknown" according to FFmpeg (since it has no codec id) and thus would otherwise be rejected by default.
This commit is contained in:
parent
a0d9967f68
commit
339828d777
|
@ -805,15 +805,19 @@ def _get_infojson_opts(self, info, infofn):
|
||||||
write_json_file(self._downloader.sanitize_info(info, self.get_param('clean_infojson', True)), infofn)
|
write_json_file(self._downloader.sanitize_info(info, self.get_param('clean_infojson', True)), infofn)
|
||||||
info['infojson_filename'] = infofn
|
info['infojson_filename'] = infofn
|
||||||
|
|
||||||
old_stream, new_stream = self.get_stream_number(info['filepath'], ('tags', 'mimetype'), 'application/json')
|
escaped_name = self._ffmpeg_filename_argument(infofn)
|
||||||
if old_stream is not None:
|
|
||||||
yield ('-map', f'-0:{old_stream}')
|
|
||||||
new_stream -= 1
|
|
||||||
|
|
||||||
yield (
|
yield (
|
||||||
'-attach', self._ffmpeg_filename_argument(infofn),
|
# In order to override any old info.json reliably we need to
|
||||||
f'-metadata:s:{new_stream}', 'mimetype=application/json',
|
# instruct FFmpeg to consider valid tracks without a codec id, like
|
||||||
f'-metadata:s:{new_stream}', 'filename=info.json',
|
# JSON attachments.
|
||||||
|
'-copy_unknown',
|
||||||
|
# This map operation allows us to actually replace any previous
|
||||||
|
# info.json data.
|
||||||
|
'-map', '-0:m:filename:info.json?',
|
||||||
|
'-attach', escaped_name,
|
||||||
|
f'-metadata:s:m:filename:{escaped_name}', 'mimetype=application/json',
|
||||||
|
f'-metadata:s:m:filename:{escaped_name}', 'filename=info.json',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user