转换/下载视频 php 或 javascript
因此,我决定添加从我的网站下载视频的功能,这些视频是从 youtube 播放的视频(youtube 视频动态嵌入在网站上)。
我读过一些关于 ffmpeg 的内容,它是基于 php 的,
我很想使用 javascript/Jquery,因为这就是我几乎所有编码的工作,但我想我有时必须学习 php。
基本上我想知道,这将如何完成?我假设您首先将视频上传到您的网站,然后继续转换,然后完成后向用户提供下载视频的链接?如果是这样,我该如何从 youtube 获取视频?
我尝试从这个网站学习...这里,但我不太明白。我只是想知道解决这个问题的最佳方法,如果有人有任何关于如何做到这一点的信息,我洗耳恭听,非常感谢!
So I've decided that adding the functionality to download videos from my website, which are videos played from youtube (youtube videos are dynamically embedded on the site).
I've read a bit about ffmpeg, which is php based
I would love to use javascript/Jquery because thats what I do almost all my coding, but I guess I have to learn php at some time.
Basically I'm wondering, how would it be done? I would assume that you would first upload the video to your site, and then proceed to convert and then when finished give a link to the user to download the video? If so, how would I go about getting the video from youtube?
I tried learning from this site...here, but I couldn't quite get it. I'd just like to know th best way of going about this, and if anyone has any information on how to do it, I'm all ears, thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法从 javascript/JQuery 调用 ffmpeg,因为它在客户端计算机上运行,而不是在您的服务器上运行。嵌入您网站上的视频数据实际上从未经过您的网络服务器,它们直接从 YouTube 传输到您网站访问者的网络浏览器。
为了从 YouTube 下载并转换视频,您必须自己(从您的服务器)建立与 YouTube 服务器的连接,下载文件(计算出实际数据流的 URL 是什么),然后通过 ffmpeg 运行它。如果您以前从未在服务器端做过任何事情,那么这不是一项简单的任务。
由于它可能需要很长时间并且需要某种后台处理任务,因此您可能不希望在单个网页请求中完成这一切。我将创建一个后台进程来下载和转换文件,然后提供 URL 将完成的文件下载到客户端。
如果这样的服务变得流行,您将需要相当大的带宽,因为您将拥有从 YouTube 下载每个文件的带宽,以及将转换后的文件提供给客户端的带宽。
您实际上是否需要以任何方式转换文件 - 或者您只是在剥离数据流并将其另存为文件之后?
You cannot invoke ffmpeg from javascript/JQuery, as that runs on the client computer, not your server. The data for the videos that are embedded on your website never actually go through your web server, they go straight from YouTube to the web browsers of your websites' visitors.
In order to download from YouTube and convert the videos, you'd have to establish a connection with the YouTube server yourself (from your server), download the file (having worked out what the URL of the actual data stream is), and then run it through ffmpeg. This is not a trivial task if you've never done anything server-side before.
As it's likely to take a long time and require some kind of background-processing task, you probably wouldn't want to do this all in a single web-page request. I would create a background process to download and convert the file, then offer the URL to download the completed file to the client.
You will have considerable bandwidth requirements if a service like this becomes popular, as you'll have the bandwidth of downloading each file from YouTube, and the bandwidth of serving your converted files to the client.
Do you actually need to convert the files in any way - or are you simply after stripping the data stream and saving it as a file?