Add packet side-data handling mechanism #2003
Merged
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 my attempt no 2 at fixing Issue #1987, which is caused by FFmpeg's
av_frame_seek
oravcodec_flush_buffers
function to discard the pal8 palette from the codec context. (I think this is very much intentional behavior.) To mitigate this behavior, we need to keep track of the palette side data, which is attached to a packet of a pal8 video stream (most certainly on the first packet but additional ones are also possible anywhere else in the video). Since pal8 pixel format is seldom used in modern video encoding, PyAV to address this issue natively is a disservice to 99%+ of the user base (I think). Instead, this PR adds ability to extract (copy) a side data from one packet and apply it to another packet.I have a rudimentary test class added to
tests/test_packet.py
but in essence we haveOther notables:
PacketSideDataTypeLiteral
to specify the side data type (rather thanEnum
as done for the frame side data). This is my personal preference but if theEnum
approach is preferable, I can modify the PR to conform to the standard.tests/assets/pyav_curated/ffmpeg
folder as the video was created via FFmpeg and its testsrc input filter.packet.py
. If they needs to reside in the stub file and must be done so manually, I'd be happy to accommodate.