如何使用 PHP 对视频进行编码?

发布于 2024-08-04 20:15:49 字数 508 浏览 6 评论 0原文

我有兴趣在我的服务器上安装 ffmpeg 或类似的东西,以便我可以上传文件,自动将它们编码为 FLV,然后提供嵌入式播放器以在我的页面上使用。

问题是我不知道从哪里开始。我不想花几天时间编写基于 Web 的编码服务,因为我对使用开箱即用的解决方案更感兴趣。

到目前为止,我的研究使我找到了 FFMPEG 以及可能的 Gallery2:它集成了 ffmpeg,gallery 2 框架提供用户帐户和FTP 上传设施。

有人知道可以在 Linux 上安装的其他开源编码解决方案吗?

I'm interested in installing ffmpeg or somesuch on my server so I can upload files, automatically encode them to FLV and then serve up a embedded player to use on my pages.

The problem is that I don't know where to start. I don't want to have to spend days coding a web based encoding service, as I'm more interested in using an out of the box solution.

My research so far has led me to FFMPEG and possibly Gallery2: it has a ffmpeg integrated and the gallery 2 framework provides user accounts and FTP upload facilities.

Is anyone aware of other open source encoding solutions which you can install on Linux?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

于我来说 2024-08-11 20:15:49

还有 memcoder,它的作用与 ffmpeg 可以,但是您必须对绑定 ffmpeg/memcoderPHP 以及上传的视频。

一般工作流程类似于:

  • 使用 PHP 向用户呈现
  • 表单 通过 post 上传
  • 文件 验证上传的文件是客户端和服务器端的视频
  • 将上传的视频存储在已知文件夹中
  • 从 PHP 运行 CLI带有所有所需参数的 命令并将文件存储在另一个已知位置
  • 如果成功则删除原始文件(可选) 将
  • 创建文件的路径存储在数据库中
  • 提供内容
  • 利润!

There is also memcoder, that does the same thing that ffmpeg does, but you will have to code the glue that binds ffmpeg/memcoder, PHP and the uploaded videos together.

The general workflow would be something like:

  • Present form to user with PHP
  • Upload file through post
  • Verify uploaded file is video both client and serverside
  • Store uploaded video in a known folder
  • From PHP, run a CLI command with all the desired parameters and store the file in another known location
  • Delete original file if success (optional)
  • Store in DB the path to the created file
  • Serve content
  • Profit!
爱的故事 2024-08-11 20:15:49

您还可以查看 VLC,因为它可以转码并充当 FLV 流的服务器。主要应用程序是用于播放视频的用户界面,但可以从命令行调用它来执行服务 - 而不是播放。

还有 libvlc,它是编写 VLC 的 C 库。 VLC 基于 ffmpeg,可能会让您的生活更轻松一些。

You could also have a look at VLC since it can transcode and act as a server for your FLV streams. The main application is a user interface to playback the video but it can be invoked from the command-line to do the serving - rather than playing.

Also there is libvlc which is the C library upon which VLC is written. VLC is based upon ffmpeg and might just make your life a little easier.

离鸿 2024-08-11 20:15:49

您应该查看您选择的编码器的文档,我过去曾成功使用过 ffmpeg。然后你的工作流程看起来像这样。

  • 使用 PHP 处理文件上传
  • 使用 exec() 向编码器输出并对视频进行编码。
  • 当 exec() 返回时,您可以在页面中提供视频

ffmpeg 非常容易通过几个命令行参数启动和运行。

You should check out the docs for your chosen encoder, I have used ffmpeg successfully in the past. Then your workflow looks something like this.

  • Handle the file upload with PHP
  • Use exec() to shell out to your encoder and encode the video.
  • When exec() returns, you can then serve the video in your page

ffmpeg was really easy to get up and running with a couple of command line arguments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文