Fix ffmpeg info parser to avoid unexpected metadata lose and type error in certain case. #2418
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is related to [#2311] and [#1860].
At first, I got a TypeError from flowing line for
self._last_metadata_field_added
was"displaymatrix"
which is casted integer, then trying operate int + str. I can easily avoid this TypeError by type conversion or check if the last metadata field was catsted. But fundamentally, why this code try to concat the fields that are not multiple line metadata?moviepy/moviepy/video/io/ffmpeg_reader.py
Lines 545 to 548 in 4dd5fe4
Then I found [#2311] caused this issue because changed code ignore none "key:value" metadata and return empty string "" as default. So above line is triggered which was intended to multiple line metadata concat.
So I think we need to handle none "key:value" metadata rather than not just ignoring them. Following keys are none "key:value" metadata I've just found in dump.c in ffmpeg original repo. And I want add them on
parse_metadata_field_value()
to parse properly.Additionally, I found for video stream there is sidedata besides metadata but currently parsed as metadata. So I separate sidedata from metadata for video stream.