vinsb Posted September 10, 2014 Share Posted September 10, 2014 (edited) 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 September 10, 2014 by vinsb Quote Link to comment https://forums.phpfreaks.com/topic/290972-creating-gif-from-video-while-uploading/ Share on other sites More sharing options...
Ch0cu3r Posted September 10, 2014 Share Posted September 10, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/290972-creating-gif-from-video-while-uploading/#findComment-1490584 Share on other sites More sharing options...
vinsb Posted September 10, 2014 Author Share Posted September 10, 2014 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...? Quote Link to comment https://forums.phpfreaks.com/topic/290972-creating-gif-from-video-while-uploading/#findComment-1490587 Share on other sites More sharing options...
Ch0cu3r Posted September 10, 2014 Share Posted September 10, 2014 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...? For youtube videos you need to use youtube's player api instead Quote Link to comment https://forums.phpfreaks.com/topic/290972-creating-gif-from-video-while-uploading/#findComment-1490589 Share on other sites More sharing options...
vinsb Posted September 10, 2014 Author Share Posted September 10, 2014 (edited) 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 September 10, 2014 by vinsb Quote Link to comment https://forums.phpfreaks.com/topic/290972-creating-gif-from-video-while-uploading/#findComment-1490590 Share on other sites More sharing options...
Ch0cu3r Posted September 10, 2014 Share Posted September 10, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/290972-creating-gif-from-video-while-uploading/#findComment-1490610 Share on other sites More sharing options...
QuickOldCar Posted September 10, 2014 Share Posted September 10, 2014 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.jpghttp://img.youtube.com/vi/youtube_video_id/1.jpghttp://img.youtube.com/vi/youtube_video_id/2.jpghttp://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 Quote Link to comment https://forums.phpfreaks.com/topic/290972-creating-gif-from-video-while-uploading/#findComment-1490621 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.