-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
mp4-tools: fix hevc 608 captions #4972
Conversation
hevc nal header is different than avc. avc nal header has the format - forbidden_zero_bit All f(1) nal_ref_idc All u(2) nal_unit_type All u(5) while hevc nal header has the format - forbidden_zero_bit f(1) nal_unit_type u(6) nuh_layer_id u(6) nuh_temporal_id_plus1 u(3) therefore - 1. need to skip 2 bytes instead of 1 when parsing the SEI body 2. to get the nal unit type, need to do (x >> 1) & 0x3f, instead of x & 0x1f
6222c35
to
6e404cb
Compare
Btw, on a different subject... looking at the code in tsdemuxer.ts, the call to parseSEIMessageFromNALu does 'discardEPB', this seems off to me, as it's already performed inside the function. Am I missing something? |
@erankor seems the discard call is redundant and probably it doesn't cause any issues doing it twice cause 2nd time will not find Emulation Prevention Bytes so it will just return the data as is, so seems like it can be removed |
Also a side note, I think MAGIC NUMBERS should start being normalized across the project and set as constants with meaningful names |
Yeah, I think that due to the parity bits in 608, having a sequence of zeroes is unlikely, if at all possible... Anyway, I think it's wrong and should be removed. |
'discardEPB' is also defined twice. Once in mp4-tools and once in tsdemuxer. |
Opened #4983 for removing the redundant discardEPB. |
English channel looks good. What's going on in the Spanish channel / Unknown CC? |
This stream has -
The player does not support 708 (it tries to parse it as 608 or something like that) so this is expected, we're getting the same behavior with AVC. We've recently implemented a module that does '608/708 -> webvtt' on the server side to work around the missing support for 708. |
hevc nal header is different than avc. avc nal header has the format - forbidden_zero_bit All f(1) nal_ref_idc All u(2) nal_unit_type All u(5) while hevc nal header has the format - forbidden_zero_bit f(1) nal_unit_type u(6) nuh_layer_id u(6) nuh_temporal_id_plus1 u(3) therefore - 1. need to skip 2 bytes instead of 1 when parsing the SEI body 2. to get the nal unit type, need to do (x >> 1) & 0x3f, instead of x & 0x1f
hevc nal header is different than avc.
avc nal header has the format -
forbidden_zero_bit All f(1)
nal_ref_idc All u(2)
nal_unit_type All u(5)
while hevc nal header has the format -
forbidden_zero_bit f(1)
nal_unit_type u(6)
nuh_layer_id u(6)
nuh_temporal_id_plus1 u(3)
therefore -
This PR will...
Fix 608 caption extraction for HEVC
Why is this Pull Request needed?
608 captions for HEVC are broken, assumes AVC NAL header format.
Are there any points in the code the reviewer needs to double check?
Resolves issues:
Checklist