diff --git a/index.js b/index.js index 8bdbc39..f7593da 100644 --- a/index.js +++ b/index.js @@ -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) diff --git a/package.json b/package.json index 3724e36..499b105 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "video-frames", - "version": "0.1.1", + "version": "1.0.0", "private": false, "description": "Client side video frames extraction as base64 encoded images", "author": "Utkarsh Verma",