[BUGFIX] Embedded null byte ffmpeg fix (#1363)

Closes https://github.com/jmbannon/ytdl-sub/issues/710

Fixes the notorious embedded null byte error seen during FFMPEG metadata writes when handling special characters.
This commit is contained in:
Jesse Bannon 2025-10-16 08:01:37 -07:00 committed by GitHub
parent 1b2e34bad4
commit 7364aac00c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -201,7 +201,11 @@ def add_ffmpeg_metadata_key_values(file_path: str, key_values: Dict[str, str]) -
"-dn", # ignore data streams
]
for key, value in key_values.items():
ffmpeg_args.extend(["-metadata", f"{key}={value}"])
# Some special characters (utf-16 maybe?) have null-byte
# which results in ffmpeg error, remove them outright
value_null_byte_removed = value.replace("\0", "")
ffmpeg_args.extend(["-metadata", f"{key}={value_null_byte_removed}"])
ffmpeg_args.extend(["-codec", "copy", "-bitexact", tmp_file_path])
FFMPEG.run(ffmpeg_args)