Anybody help me i want to developing a website using php code. GIF-KING this is my website i have completed jpeg image to gif creator but how to create GIF image from YouTube URL like yt2gif
I tried to search Google but there is not gives any sufficient result to fulfill my requirement.
I got the code upload video to GIF creator but unable to find the script making YouTube URL to GIF creator.
I got one solution first download YouTube video by using YouTube API. then convert it to in GIF images. But that is not the right way. i am unable to convert it in the middle part. Always convert from starting Also it is not possible to download huge number of video from YouTube.
See my process of creating GIF images from YouTube URL.
Screenshot-1 :
Copy the YouTube URL
Screenshot-2 :
Paste it in the website http://www.gif-king.com/make-your-gif3 see below screenshot.
Click on Create Gifs
after some times the video details will appear See screenshot-3.
Screenshot-3 :
After click on Make Gif
this video will convert to GIF.
It is working for a small video. but not working it for big video.
My php code:
ajax.php
if(isset($_REQUEST['vid'])){
$vidID=$_REQUEST['vid'];
if($vidID){
include('curl.php');
include('youtube.php');
$tube = new youtube();
$links = $tube->get("http://www.youtube.com/watch?v=".$vidID);
$getVideo=$links[3]['url']; //Get the avi video from youtube
$cate=mysql_query("select * from category ORDER BY id ");
while($categoryName=mysql_fetch_array($cate)){
$getCatRes .= '<option value="'.$categoryName['id'].'">'.$categoryName['name'].'</option>';
}
if($getVideo) {
$url = "http://gdata.youtube.com/feeds/api/videos/". $vidID;
$doc = new DOMDocument;
$doc->load($url);
$title = $doc->getElementsByTagName("title")->item(0)->nodeValue;
$duration = $doc->getElementsByTagName('duration')->item(0)->getAttribute('seconds');
if($duration > 1200){
$array[] = array('result'=>'error','message'=>'ERROR!!! Maximum 20 minutes video allowed');
}
else{
$newVideo = "gifking_".time().".avi";
$videoUploaded=file_put_contents("myvideo/".$newVideo,file_get_contents($getVideo));
if($videoUploaded){
$video='<iframe width="360" height="240" frameborder="0" allowfullscreen="" src="http://www.youtube.com/embed/'.$vidID.'?enablejsapi=1&playerapiid=ytplayer&version=3&cc_load_policy=0&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0&theme=light"></iframe>';
$video_title='<input type="text" class="add-gif-textbox" name="title" id="title" placeholder="Title" value="'.$title.'" />';
$category='<select class="add-gif-dropdown" id="cat_id" name="cat_id">
'.$getCatRes.'
</select>';
$tag='<input type="text" class="add-gif-textbox" name="tag" id="tag" placeholder="tiger,book,flower" />';
$submitBtn='<input id="button" class="button1" type="submit" value="Make Gif" name="submit">';
$array[] = array('result'=>'success','title'=>$video_title,'category'=>$category,'video'=>$video,'duration'=>$duration,'tag'=>$tag,'filename'=>$newVideo,'submit_btn'=>$submitBtn);
}
else{
$array[] = array('result'=>'error','message'=>'ERROR!!! Uploading image please try again');
}
}
}
else{
$array[] = array('result'=>'error','message'=>'ERROR!!! Invalid video id');
}
echo json_encode($array);
}
}
Please suggest me how to creating that in php code?