rnicholus / frame-grab.js Goto Github PK
View Code? Open in Web Editor NEWGrab, manipulate, and render <video> frames
License: MIT License
Grab, manipulate, and render <video> frames
License: MIT License
Do this as part of the next release.
Badges should be:
[![Dependency Status](https://david-dm.org/rnicholus/frame-grab.js.svg?theme=shields.io)](https://david-dm.org/rnicholus/frame-grab.js)
[![devDependency Status](https://david-dm.org/rnicholus/frame-grab.js/dev-status.svg?theme=shields.io)](https://david-dm.org/rnicholus/frame-grab.js#info=devDependencies)
Update README to note that a polyfill is needed in IE.
This value is likely to be a string if coming from user input (for example, via window.prompt
). It seems reasonable to attempt to coerce this via parseInt
before I declare the parameter invalid.
I use frame-grab.js with dropzone.js. Here is the code:
mmdDz.on("addedfile", function(file) { var comps = file.name.split("."); if (comps.length === 1 || (comps[0] === "" && comps.length === 2)) { return; } var ext = comps.pop().toLowerCase(); if (ext == 'mov' || ext == 'mpeg' || ext == 'mp4' || ext == 'wmv') { console.log("extention: " + ext); FrameGrab.blob_to_video(file).then( function videoRendered(videoEl) { var frameGrab = new FrameGrab({video: videoEl}); var imgEl = file.previewElement.querySelector("img"); console.log("img: " + imgEl + " /// videoEl: " + videoEl); frameGrab.grab(imgEl, 1, 220).then( function frameGrabbed(itemEntry) { console.log("file: " + itemEntry); self.emit('thumbnail', file, itemEntry.container.src); }, function frameFailedToGrab(reason) { console.log("Can't grab the video frame from file: " + file.name + ". Reason: " + reason); } ); }, function videoFailedToRender(reason) { console.log("Can't convert the file to a video element: " + file.name + ". Reason: " + reason); } ); } });
It works fine on desktop & safari mobile emulator but it doesn't on iphone or ipad. I can't catch why... No errors in console log
console.log("extention: " + ext)
- returns right extention
console.log("img: " + imgEl + " /// videoEl: " + videoEl);
- returns nothing
<img>
or <canvas>
.<video>
, seeking to the correct time in the clone, and grabbing the frame from there.Populate a timeline with appropriately placed frame grabs. An element representing the timeline will need to be supplied, along with the <video>
, and the exact frame rate. Frame-grab.js will generate frame images on the timeline, taking into account the timeline's width and height. The timeline will be filled, and the left edge of a frame image on the timeline will coincide with the frame in the video that represents that image.
Instead, it erroneously uses the current time of the source video clone, created during construction of the instance.
Hello.
I need to make a slider to select a frame for preview. So, your API is suitable except one thing. How can I get a total frames count to use it as maximum slider value? Is it possible using your API or I need another way?
Thank you.
I should probably console.error
all error messages, just in case integrator's aren't handling a promise rejection (which would be invoked if the promise throws).
Allow a "story" to be created using appropriately (and generally evenly spaced) frame grabs from a source video. The number of frame grabs should be specified. Sizes for the frame grabs can also be specified. The result will be an ordered array of <canvas>
or <img>
elements, depending on the requirements of the caller.
make_story
method that takes the following params: type of container (string: canvas or img), number of images (integer), size of images (integer)). This method will return a promise that will include an array of canvases or imgs passed into the resolve callback.duration
of the video.Currently, you must generate one of these yourself, and pass it into the method. It seems reasonable to ask frame-grab to do this for you if you just pass in a "img" or "canvas" string.
I use frame-grab inside of a dropzone.js application to fetch a video thumbnail for each added file. If i add a lot of files, the frame-grab function may freeze the browser.
So is there a way to run it async to await the result for each file? Also i would like to show a loading overlay during frame-grabbing, but async/await does not seem to work with the frameGrab function.
test
Earlier we disused how it was possible to use your plug-in to create thumbnails of video files that a user would select the src via File Input. Is there an example that you could piece together of this and provide an example in a zip or JSFiddle?
Test have been divided up into two groups: simple and complex.
The complex tests exercise code that works with actual <video>
elements. These tests will (mostly) not run in PhantomJS due to its lack of support for media. The seemingly obvious solution to this is to pull in karma and automatically run these tests in "real" browsers. Karma makes this relatively simple, and we can even download and install Firefox on Travis in order to run these test in our CI environment as well.
Unfortunately, Karma's QUnit adapter seems to have some issues. I wasn't able to get any the <video>
based tests to pass in Chrome when launched via Karma. I wasn't able to figure out the specific issue before I gave up and decided that I wasn't ready to invest days on this when I can easily run the tests in all browsers on my dev machine simply by starting up a server and pointing to the HTML page for the QUnit tests. Also, the Karma-bundled QUnit adapter doesn't report the number of tests run either, and a failing async test seems to cause the runner to hang.
Maybe I'll allocate some time to fix these issues or work around them in the future. That's what this case is for.
The simple tests cover everything not directly related to <video>
elements, such as tests of the timecode to seconds logic, etc. These are run via a grunt task and, of course, in Travis.
The following snipit below will only work in firefox. How can I make the player take a screenshot at a specific time onload without pressing play and the grab frame button?
$("#videoPlayer").on("canplay",function() { this.currentTime = 13;});
Also, the plugin is not supported in Safari
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.