Jump to content

Creating gif from video while uploading


vinsb

Recommended Posts

Hello,

 

How can I make gif from video while uploading it or after uploaded? Is there any tutorial.. I've been searched but didn't found anything.

The reason I want this is because when I upload video then I will show few thumbnails of the video on the page. Then when user hover the video will play short gif from the video 2-5 seconds and when the user click on video will play the video.. Hope you get what I mean.. I don't know how to explain it better. Just point me somewhere to read or watch about this..

 

Thank's in advanced!

 

p.s. Sorry for my English!

 

EDIT:

Here is the exaplme.. when you hover over the video an hold your mouse there it will play some gif

http://gifsoup.com/faq.php

 

Is it possible this?

Edited by vinsb
Link to comment
Share on other sites

You can use ffmpeg to read the video and produce a preview (still or animated)  gif image of the video. Google  "php ffmpeg video gif" yields many results.

 

To have the video play you could use the HTML5 media player

Now I store youtube link in database and play the video from the link. I think this will be the problem and I can't use it with html5 video player...?

Link to comment
Share on other sites

Yes, I'm using it now. So I need to work with ffmpeg for the gif. That's ok.

Just one more question - So as I see I must download first the video and then make the gif .. then save the video link in database and somehow connect the gif to that video.. 

 

Honestly, I'm not that advanced and I don't see how this will hapen. If I upload/save video/link only on the site is ok.. I will make this. But every registered user can upload video.. In this case I will need to store the video and make gif ..

 

It will be something like

ffmpeg + ffmpeg -i video_origine.avi gif_anime.gif

But can I put the link to the video instead of 'video_origine.avi'?

Edited by vinsb
Link to comment
Share on other sites

 

 

t one more question - So as I see I must download first the video and then make the gif .. then save the video link in database and somehow connect the gif to that video.. 

When you say video do you mean only youtube videos? If so  then you dont need to do anything. The user just needs to give the url to the youtube video. You'd save that link to your database then you'd use youtube player api to embed that video in your webpage.

 

If the user is linking to videos from other video sharing sites (eg vimeo, metacafe etc) then you'd need to use their receptive video player api's for embedding those videos in your webpage too.

 

The only time you;d need to use ffmpeg will be if the user uploads raw video file (mpg, avi etc) from their device. With ffmpeg you can generate the preview image. In order to use ffmpeg you'd need to check with your host to see if it is available as it is not a standard feature that comes with PHP. 

 

ffmpeg is a third party command line tool. In order to use it you need to send commands to it to tell it what to do. Each available command are described here

 

I cannot tell you what specific commands you need to perform to do what you want to do as I have never used ffmpeg. But as I said before google "php ffmpeg video gif" and you should find many examples of how to do video previews using ffmpeg and PHP.

Link to comment
Share on other sites

That site you linked to must use a youtube downloader such as youtube-dl on their host.

Then grab x many frames with ffmpeg/avconv and turn it into a gif file.

 

 

For a very basic tutorial showing some code.

http://www.atrixnet.com/animated-gifs/

 

To me is a large hassle to go through all this for a preview animated gif image.

 

You could just show an image preview using one of the following urls as the image source.

 

Use the video id where see red.

http://img.youtube.com/vi/youtube_video_id/0.jpg
http://img.youtube.com/vi/youtube_video_id/1.jpg
http://img.youtube.com/vi/youtube_video_id/2.jpg
http://img.youtube.com/vi/youtube_video_id/3.jpg

http://img.youtube.com/vi/youtube_video_id/default.jpg

http://img.youtube.com/vi/youtube_video_id/hqdefault.jpg

http://img.youtube.com/vi/youtube_video_id/mqdefault.jpg

http://img.youtube.com/vi/youtube_video_id/sddefault.jpg

http://img.youtube.com/vi/youtube_video_id/maxresdefault.jpg

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.