1

I'm trying to create a web application using PHP (Laravel 5.8) where user can past link of any video found on the Internet (like Youtube, Dailymotion ... etc), then cut the video.

Cutting the video the video both in front-end and back-end is easy to do, I'm using PHP-FFMPeg to do it in server side.

My problem is that I couldn't find a solution to open a remote video from my PHP script, i.e if user past this link "https://www.dailymotion.com/video/x6rh0" I would open it then make a clip.

This my code :

    $ffmpeg = FFMpeg\FFMpeg::create();
    $url = "https://www.dailymotion.com/video/x6rh0";
    $video = $ffmpeg->open($url);
    $clip = $video->clip(FFMpeg\Coordinate\TimeCode::fromSeconds(30), FFMpeg\Coordinate\TimeCode::fromSeconds(15));
    $clip->save(new FFMpeg\Format\Video\X264('libmp3lame', 'libx264'), public_path().'/videos/video2.avi');

I'm using PHP Laravel framework.

Please, how can I open a video from URL using PHP-FFMpeg, this is my question.

C.Ad
  • 48
  • 4
  • 2
    Use youtube-dl or similar to acquire the video. Do not expect ffmpeg to accept arbitrary URLs that are not direct links to videos. – llogan Dec 20 '19 at 19:36
  • Do you think that I have to download the video first to my server then edit it with FFMpeg ? – C.Ad Dec 20 '19 at 19:46
  • You don't have to download it, but you need to have the URL of the video. Not a webpage that has a video as one of it elements. – szatmary Dec 20 '19 at 21:26
  • `youtube-dl -g https://www.dailymotion.com/video/x6rh0` should give you an ffmpeg compatible link (assuming the site is supported by youtube-dl). – cOle2 Dec 20 '19 at 21:47

0 Answers0