fix: Skip NAL header byte when reading SPS profile data in HlsMuxer
The SPS NAL unit format is: [NAL header, profile_idc, constraint_flags, level_idc, ...] The code was incorrectly reading from byte 0 (NAL header, typically 0x67) instead of byte 1 (profile_idc). This produced invalid codec strings like `avc1.676400` instead of valid ones like `avc1.64001f`, causing Shaka Player on web to fail with error 4032 (unable to parse codec). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -761,9 +761,11 @@ class HlsMuxer(
|
||||
val output = ByteArrayOutputStream()
|
||||
val dos = DataOutputStream(output)
|
||||
|
||||
val profileIdc = if (sps.isNotEmpty()) sps[0].toInt() and 0xFF else 0x42
|
||||
val profileCompat = if (sps.size > 1) sps[1].toInt() and 0xFF else 0x00
|
||||
val levelIdc = if (sps.size > 2) sps[2].toInt() and 0xFF else 0x1F
|
||||
// SPS NAL unit format: [NAL header, profile_idc, constraint_flags, level_idc, ...]
|
||||
// Skip byte 0 (NAL header, typically 0x67) to get the actual profile data
|
||||
val profileIdc = if (sps.size > 1) sps[1].toInt() and 0xFF else 0x42
|
||||
val profileCompat = if (sps.size > 2) sps[2].toInt() and 0xFF else 0x00
|
||||
val levelIdc = if (sps.size > 3) sps[3].toInt() and 0xFF else 0x1F
|
||||
|
||||
dos.writeByte(1) // configuration version
|
||||
dos.writeByte(profileIdc) // AVC profile
|
||||
|
||||
Reference in New Issue
Block a user