0

I want made a gif from YouTube URL in PHP by using FFMPEG

I want execute shell command

$regex_pattern = "/(youtube.com|youtu.be)\/(watch)?(\?v=)?(\S+)?/";
    $match;
    if(preg_match($regex_pattern, $old_src, $match)) {
     $vidID = $match[4];
     $vidID = str_replace('embed/', '', $vidID);
     $image1 = 'https://img.youtube.com/vi/'.$vidID.'/1.jpg';
     $image2 = 'https://img.youtube.com/vi/'.$vidID.'/2.jpg';
     $image3 = 'https://img.youtube.com/vi/'.$vidID.'/3.jpg';
     $file1 = file('https://img.youtube.com/vi/'.$vidID.'/1.jpg');
     $file2 = file('https://img.youtube.com/vi/'.$vidID.'/2.jpg');
     $file3 = file('https://img.youtube.com/vi/'.$vidID.'/3.jpg');
     $images = array(
        $image1,$image2,$image3
     );
     $image = array(
        $file1,$file2,$file3
     );
     // echo "<pre>"; print_r($file1); exit;
        $test = shell_exec("/usr/local/bin/ffmpeg -f {$image1} -i *.jpg -vcodec libx264 out.mp4 2>&1");
     echo "<pre>"; print_r($test); exit  }
qasim
  • 1
  • 1
    Break this into smaller problems. First, get the images from YouTube using PHP. Once you have that solved, figure out how to create an animated gif from the CLI, no PHP. Then, bring the CLI into PHP, but work with local static images. Lastly, pull it all together. – Chris Haas Dec 24 '21 at 14:13
  • thanks for your feed back we also get image from youtube firstly that part work fine next step which i am not sure that how to create animation from that images if you have any solution kindly help – qasim Dec 27 '21 at 04:17
  • Does this answer your question? [How to create a video from images with FFmpeg?](https://stackoverflow.com/questions/24961127/how-to-create-a-video-from-images-with-ffmpeg) – Chris Haas Dec 27 '21 at 14:23

0 Answers0