-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0aff8d
commit f93ff16
Showing
5 changed files
with
53 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# @pear-rec/web | ||
|
||
## 1.4.11 | ||
|
||
fix: 动图导出 bug、视频解析动图 bug | ||
|
||
## 1.4.10 | ||
|
||
feat: 网站统计 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,38 @@ | ||
class Canvas2DRenderer { | ||
#canvas = null; | ||
#ctx = null; | ||
#timeStart = 0; | ||
#timeEnd = 0; | ||
#num = 0; | ||
#index = 0; | ||
|
||
constructor(canvas) { | ||
constructor(canvas, option) { | ||
this.#canvas = canvas; | ||
this.#ctx = canvas.getContext('2d'); | ||
this.#timeStart = option.timeStart; | ||
this.#timeEnd = option.timeEnd; | ||
this.#num = option.num; | ||
} | ||
|
||
draw(frame) { | ||
this.#canvas.width = frame.displayWidth; | ||
this.#canvas.height = frame.displayHeight; | ||
this.#ctx.drawImage(frame, 0, 0, frame.displayWidth, frame.displayHeight); | ||
if ( | ||
(this.#index < this.#num || !this.#num) && | ||
((this.#timeStart == 0 && this.#timeEnd == 0) || | ||
(this.#timeStart <= frame.timestamp && this.#timeEnd > frame.timestamp)) | ||
) { | ||
this.#index++; | ||
this.#canvas.width = frame.displayWidth; | ||
this.#canvas.height = frame.displayHeight; | ||
this.#ctx.drawImage(frame, 0, 0, frame.displayWidth, frame.displayHeight); | ||
this.#canvas.convertToBlob({ type: 'image/png' }).then((blob) => { | ||
let videoFrame = { | ||
fileName: `pear-rec_${+new Date()}.png`, | ||
fileData: blob, | ||
frameDuration: (frame.duration / 1000).toFixed(0), | ||
}; | ||
self.postMessage({ videoFrame, index: this.#index }); | ||
}); | ||
} | ||
frame.close(); | ||
this.#canvas.convertToBlob({ type: 'image/png' }).then((blob) => { | ||
let videoFrame = { | ||
fileName: `pear-rec_${+new Date()}.png`, | ||
fileData: blob, | ||
frameDuration: (frame.duration / 1000).toFixed(0), | ||
}; | ||
self.postMessage({ videoFrame }); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters