用php下载youtube-dl / ffmpeg下载youtube视频

I have been using youtube-dl for a long time, and I now want to install it on my dedicated server to make it easier for me to download content.

I created a php script that allows me to download the video of my choice to the server, then I download it to my computer, pretty cool!

I am now trying to improve this script in order to redirect only the feed to avoid uploading the video to the server.

Example with this site: https://mpgun.com It seems to redirect the stream without downloading the video to the server. If you try to download a video that lasts 3 hours, the site will offer you the download immediately!

I think ffmpeg allows you to do that, only I don't know where to start in the code.

Do you have any idea how to set this up in php?

Thank you

What you are looking for is the --get-url switch for youtube DL.

For example, execute the command:

youtube-dl -f best --get-url "https://www.youtube.com/watch?v=fPXqHOpVV80"

This will output the direct download link the the video.