{"id":28228387,"url":"https://github.com/imshaikot/video-thumb-generator","last_synced_at":"2025-06-12T17:30:53.116Z","repository":{"id":57392240,"uuid":"115913289","full_name":"imshaikot/video-thumb-generator","owner":"imshaikot","description":"Capture thumbnails/screenshots from respective video over HTML5 environment","archived":false,"fork":false,"pushed_at":"2018-01-07T08:47:02.000Z","size":111,"stargazers_count":21,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-03T09:02:32.204Z","etag":null,"topics":["html-media","html5","javascript","screenshot","video"],"latest_commit_sha":null,"homepage":"https://imshaikot.github.io/video-thumb-generator","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imshaikot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-01T10:47:11.000Z","updated_at":"2024-05-07T15:02:44.000Z","dependencies_parsed_at":"2022-09-11T21:01:19.608Z","dependency_job_id":null,"html_url":"https://github.com/imshaikot/video-thumb-generator","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/imshaikot/video-thumb-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imshaikot%2Fvideo-thumb-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imshaikot%2Fvideo-thumb-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imshaikot%2Fvideo-thumb-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imshaikot%2Fvideo-thumb-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imshaikot","download_url":"https://codeload.github.com/imshaikot/video-thumb-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imshaikot%2Fvideo-thumb-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259511984,"owners_count":22869324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html-media","html5","javascript","screenshot","video"],"created_at":"2025-05-18T14:09:56.256Z","updated_at":"2025-06-12T17:30:53.110Z","avatar_url":"https://github.com/imshaikot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003ch1 align=\"center\"\u003e Generate/capture screenshots from videos on the fly over HTML5 \u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  This library will let you grab screenshots from video tracks that supported by modern web browsers and will give you standard images (ObjectURL or base64 DataURL) \n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.org/package/video-thumb-generator\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/video-thumb-generator.svg?style=flat-square\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/imshaikot/video-thumb-generator\"\u003e\u003cimg src=\"https://api.travis-ci.org/imshaikot/video-thumb-generator.svg\" /\u003e\u003c/a\u003e\n\n  \u003ca href=\"https://github.com/imshaikot/video-thumb-generator/blob/master/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/imshaikot/video-thumb-generator.svg\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"http://standardjs.com\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/code%20style-standard-brightgreen.svg\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Demo\n\n\u003ca href=\"https://imshaikot.github.io/video-thumb-generator/\"\u003ehttps://imshaikot.github.io/video-thumb-generator/\u003c/a\u003e\n\n## Installation\n\n```bash\n$ npm install video-thumb-generator --save\n```\nOR umd builds are also available\n```\n\u003cscript src=\"https://unpkg.com/video-thumb-generator/umd/VideoToThumb.min.js\"\u003e\u003c/script\u003e\n```\n\n## Getting Started\n\nThis is a tiny library to get screenshots from video tracks either from your local filesytem OR same-origin based URL.\n\n```js\n// Using ES6\nimport VideoToThumb from 'video-thumb-generator'; // This is a default export, so you don't have to worry about the import name\n\n// Not using ES6\nvar VideoToThumb = require('video-thumb-generator');\n```\n\n## Example and API\n\nThe constructor accepts 3 types of value as its parameter. \n  1. HTML5 File Object (Ex. ```dataTransfer.files[0]```)\n  2. Any existing/active HTML Video element's DOM object/instance (Ex. ```document.getElementById('video')```)\n  3. Same origin video URL as string. (Ex. ```'http://mydomain.com/video.avi'```)\n```js\nconst videoToThumb = new VideoToThumb(file.files[0]); // OR you could pass instantiate new VideoToThumb('http://mydomain.com/video.mp4') OR maybe new VideoToThumb(document.getElementById('video'))\n```\nThe instance of VideoToThumb contains a bunch of method (which are chained) but to get strated you have to call the `load()` method before any other chained method being called\n\n```js\nconst videoToThumb = new VideoToThumb(file.files[0]);\nvideoToThumb\n.load(); // This will start the process\n```\nAfter the `.load()` being called then you're free to call other methods. Like `.positions([])` method - this method will accept a parameter as an Array of the positions (in second) of video duration where you want to capture the screenshots. The Defualt value is `[1]`\n```js\nconst videoToThumb = new VideoToThumb(file.files[0]);\nvideoToThumb\n.load()\n.positions([223, 555, 632, 104]);\n```\nIn order to set the returned screenshots size - you can call `.size([320, 240])` - default is `[320, 240]`\n```js\nconst videoToThumb = new VideoToThumb(file.files[0]);\nvideoToThumb\n.load()\n.positions([223, 555, 632, 104])\n.size([480, 360]); // 480x360 pixel\n```\nYou can also customize the screenshot coordinates by calling `xy([0, 0])` this method. This method will decide from which coordinate to start capturing the snapshots.\n```js\nconst videoToThumb = new VideoToThumb(file.files[0]);\nvideoToThumb\n.load()\n.positions([223, 555, 632, 104])\n.xy([0, 0])\n.size([480, 360]);\n```\nAnother method `type()` - this method to tell whether you want the image to be returned as `base64` dataURL OR HTML5 `objectURL` - default `'objectURL'`\n```js\nconst videoToThumb = new VideoToThumb(file.files[0]);\nvideoToThumb\n.load()\n.xy([0, 0])\n.size([480, 360])\n.positions([223, 555, 632, 104])\n.type('base64')\n```\nIn order to track errors during the process (media, canvas or input) - this method will help you to track and this method accept a parameter of `errorCallback`\n\u003cb\u003eCaution\u003c/b\u003e: Few Media Errors are still silent and won't reach the error callback (I'll work to get it done)\n```js\nconst videoToThumb = new VideoToThumb(file.files[0]);\nvideoToThumb\n.load()\n.xy([0, 0])\n.size([480, 360])\n.positions([223, 555, 632, 104])\n.type('base64')\n.error(function(err) {\n  console.log(JSON.stringify(err));\n})\n```\nAnd finally the `done(callback)` method. Remember the `load()` method to start and now `done` to end the process and your job done. This method accept a parameters `successCallback`.\nThe success callback returns the successive screenshots that have been taken as an array.\n```js\nconst videoToThumb = new VideoToThumb(file.files[0]);\nvideoToThumb\n.load()\n.xy([0, 0])\n.size([480, 360])\n.positions([223, 555, 632, 104])\n.type('base64')\n.error(function(err) {\n  console.log(JSON.stringify(err));\n})\n.done(function(imgs) {\n  imgs.forEach(function(img) {\n    var elem = new Image();\n    elem.src = img;\n    document.body.appendChild(elem);\n  })\n})\n```\n\nNote: All methods are chained, that means every method returns the same instance/context and that means you can call any method in any order but `load()` method must be called at the top and `done()` at the bottom, unless you want some silent errors ;)\n\n\u003cb\u003eWarnings:\u003c/b\u003e few errors are still silent and won't reach the error callback. Feel free to make pull request.\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimshaikot%2Fvideo-thumb-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimshaikot%2Fvideo-thumb-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimshaikot%2Fvideo-thumb-generator/lists"}