Add support for Matroska zlib compressed subtitle tracks #3211
Open
inorichi wants to merge 2 commits into
Open
Add support for Matroska zlib compressed subtitle tracks #3211inorichi wants to merge 2 commits into
inorichi wants to merge 2 commits into
Conversation
94528b2 to
cda36af
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PR solves #2361
The first commit implements the changes to support zlib compressed subtitles in SUBRIP, ASS, SSA and VTT.
PGS and VOBSUB already support zlib compressed subtitles (I verified this by creating a sample file with zlib compression) so no changes were needed.
The second commit adds the samples and new tests and dumps for those samples.
The implementation looks for the master element
ID_CONTENT_COMPRESSIONand when present, enables a boolean flag in the current track.Later, when a subtitle block is processed, a new
inflatedSubtitleSampleis used to hold the uncompressed data, and follows a similar approach toPgsParserandVobsubParserby using the methodUtil.maybeInflateand finally copies the result to the realsubtitleSample.The method
resetcould not be used because the input already contains the codec prefix at the beginning, so I usedSystem.arraycopyafter the prefix. Let me know if you prefer another approach.The samples were created from the existing ones with the closest tool that created them in the first place, so I've used both ffmpeg and mkvmerge. When running diffs on the dumps of the original mkv and derived mkv with zlib compression, the only changes are in the seekMap positions, so I don't think we can reuse other dumps as it's done for other tests, but I'm no expert on the seekMap so let me know if it's possible.
I've also mixed usages of the null terminated samples because zlib data may contain a null byte, so the decompression must be done before looking for a null byte.
The commands used were either of the two: