diff --git a/.changeset/green-colts-impress.md b/.changeset/green-colts-impress.md new file mode 100644 index 00000000..1cf5b44c --- /dev/null +++ b/.changeset/green-colts-impress.md @@ -0,0 +1,5 @@ +--- +'@webav/av-cliper': patch +--- + +fix: IDR frame recognition for HEVC #306 diff --git a/packages/av-cliper/src/clips/mp4-clip.ts b/packages/av-cliper/src/clips/mp4-clip.ts index fc5c58c0..f5c1bb49 100644 --- a/packages/av-cliper/src/clips/mp4-clip.ts +++ b/packages/av-cliper/src/clips/mp4-clip.ts @@ -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;