How can I get the first frame of a video file in javascript as an image?
not client side atleast.
Pim Jager
2009-07-21 15:55:56
Javascript runs on the client side, brainiac.
Josh Stodola
2009-07-23 23:11:25
+1
A:
As mentioned, Javascript is not able to do this.
If you want to create thumbnails for your videos you have to create the thumbnail server side and then simply serve up the image on the client as you would any other image.
My method of choice for accomplishing this is the ffmpeg decoder. It can handle a multitude of file formats and is able to do what you want. So if you have a video named hello.avi
, you might do:
ffmpeg -itsoffset -1 -i /path/to/hello.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 200x150 /path/to/hello.jpg
You can run this command (fixing the paths and dimensions...) with whatever server-side language you are using and it would create a thumbnail of the video file.
Paolo Bergantino
2009-07-21 23:11:06