Skip to content

TypeError when parsing FFmpeg metadata due to string + float concatenation #2423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
b2220765063 opened this issue Apr 23, 2025 · 0 comments
Labels
bug Issues that report (apparent) bugs.

Comments

@b2220765063
Copy link

moviepy crashes when parsing FFmpeg metadata if a field continuation attempts to concatenate a string and a float. This happens when _last_metadata_field_added refers to a value in metadata that is a float, and the parser assumes all metadata values are strings.

TypeError: can only concatenate str (not "float") to str
...
value = str(self._current_stream["metadata"][field]) + "\n" + value

This happens in FFmpegInfosParser.parse() when handling metadata field continuation lines where field == "".

Problematic Code (line 550 in video/io/ffmpeg_reader.py)

if field == "":
field = self._last_metadata_field_added
value = self._current_stream["metadata"][field] + "\n" + value

If self._current_stream["metadata"][field] is a float, this crashes.

Proposed Fix

if field == "":
field = self._last_metadata_field_added
value = str(self._current_stream["metadata"][field]) + "\n" + value

Environment
• OS: macOS
• Python: 3.12
• moviepy: 1.0.3
• ffmpeg: 6.1
• Video: .mov and .mp4 files with metadata fields like vendor_id, duration, etc.

This complements PR #2311, which fixed crashes due to colon-less metadata lines. However, this bug is still possible even after that patch, especially when the previous metadata field contains a float.

@b2220765063 b2220765063 added the bug Issues that report (apparent) bugs. label Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs.
Projects
None yet
Development

No branches or pull requests

1 participant