Skip to content

Commit

Permalink
fix: IDR frame recognition for HEVC #306
Browse files Browse the repository at this point in the history
  • Loading branch information
hughfenghen committed Oct 23, 2024
1 parent 40bed0c commit 3019a88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/green-colts-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@webav/av-cliper': patch
---

fix: IDR frame recognition for HEVC #306
3 changes: 2 additions & 1 deletion packages/av-cliper/src/clips/mp4-clip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,8 @@ function isIDRFrame(u8Arr: Uint8Array, type: MP4Sample['description']['type']) {
if (type === 'avc1') {
if ((dv.getUint8(i + 4) & 0x1f) === 5) return true;
} else if (type === 'hvc1') {
if (((dv.getUint8(i + 4) >> 1) & 0x3f) === 20) return true;
const nalUnitType = (dv.getUint8(i + 4) >> 1) & 0x3f;
if (nalUnitType === 19 || nalUnitType === 20) return true;
}
// 跳至下一个 NALU 继续检查
i += dv.getUint32(i) + 4;
Expand Down

0 comments on commit 3019a88

Please sign in to comment.