Skip to content

Commit

Permalink
fix: maybe timeout for decode audio when tick a too large time
Browse files Browse the repository at this point in the history
  • Loading branch information
hughfenghen committed Dec 12, 2024
1 parent 7b87464 commit 443516f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-dragons-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@webav/av-cliper': patch
---

fix: maybe timeout for decode audio when tick a too large time
8 changes: 4 additions & 4 deletions packages/av-cliper/src/clips/mp4-clip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,10 +817,10 @@ class AudioFrameFinder {
#dec: ReturnType<typeof createAudioChunksDecoder> | null = null;
#curAborter = { abort: false, st: performance.now() };
find = async (time: number): Promise<Float32Array[]> => {
if (this.#dec == null) {
this.#reset();
} else if (time <= this.#ts || time - this.#ts > 0.1e6) {
this.#reset();
const needResetTime = time <= this.#ts || time - this.#ts > 0.1e6;
if (this.#dec == null || needResetTime) this.#reset();

if (needResetTime) {
// 前后获取音频数据差异不能超过 100ms(经验值),否则视为 seek 操作,重置解码器
// seek 操作,重置时间
this.#ts = time;
Expand Down

0 comments on commit 443516f

Please sign in to comment.