This commit is contained in:
Utkarsh Verma
2022-04-29 16:50:08 +05:30
parent 8395aa3b88
commit 99c3cbeb91
2 changed files with 7 additions and 5 deletions

View File

@@ -15,9 +15,11 @@ module.exports = async options => {
}
const fallbackToDefault = (property, defaultValue) => {
options[property] = Object.prototype.hasOwnProperty.call(options, property) ? options[property] : defaultValue
options[property] = hasOwnProperty.call(options, property) ? options[property] : defaultValue
}
const hasOwnProperty = Object.prototype.hasOwnProperty
// Buffer Video Element
const video = document.createElement('video')
video.src = options.url
@@ -69,8 +71,8 @@ module.exports = async options => {
const interval = (options.endTime - options.startTime) / (options.count + 1)
// Set Width and Height
let isWidthSet = Object.prototype.hasOwnProperty.call(options, 'width')
let isHeightSet = Object.prototype.hasOwnProperty.call(options, 'height')
let isWidthSet = hasOwnProperty.call(options, 'width')
let isHeightSet = hasOwnProperty.call(options, 'height')
const videoDimensionRatio = video.videoWidth / video.videoHeight
// Reset Width and Height if not valid
@@ -106,7 +108,7 @@ module.exports = async options => {
await new Promise(resolve => { seekResolve = resolve })
context.clearRect(0, 0, canvas.width, canvas.height)
context.drawImage(video, 0, 0, canvas.width, canvas.height)
frames.push(canvas.toDataURL(options.format))
frames.push({ offset: video.currentTime, image: canvas.toDataURL(options.format) })
index++
}
resolve(frames)