远程ftp登录并将flv转换为mp3?

发布于 2024-10-04 04:36:03 字数 246 浏览 1 评论 0原文

我试图找出通过 php 命令登录到远程服务器并运行命令将 FLV 文件转换为 MP3 (然后可能将其移动到本地服务器)的最佳方法?

我可以稍后移动该文件,但我需要按此顺序进行操作,因为远程服务器托管 ffmpeg。

使用它可以在本地完成:

exec(ffmpeg -i vid.flv -acodec copy output.mp3);

我如何远程完成?

谢谢!

I am trying to figure the best way to login via php command to a remote server and run a command to convert a FLV file into an MP3 (and then possibly moving it to the local server)?

I can always move the file later but I need to do it in this order as the remote server hosts ffmpeg.

Using this will do it locally:

exec(ffmpeg -i vid.flv -acodec copy output.mp3);

How can I do it remotely?

Thanks!

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

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

发布评论

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

评论(4

怕倦 2024-10-11 04:36:03

您无法通过 FTP 执行远程命令。

如果您可以通过 SSH 访问计算机,则可以使用 SSH2 扩展 PHP 并通过 SSH 执行它。

You cannnot execute remote commands via FTP.

If you have SSH access to the machine, you can use the SSH2 extension for PHP and execute it via SSH.

执妄 2024-10-11 04:36:03

查看 SSH2 库 (http://php.net/manual/en/book.ssh2 .php)了解如何远程运行命令,以及 Curl 库 (http: //php.net/manual/en/book.curl.php)了解如何下载远程文件。

Look into the SSH2 library (http://php.net/manual/en/book.ssh2.php) for how to run commands remotely, and the Curl library (http://php.net/manual/en/book.curl.php) for how to download remote files.

束缚m 2024-10-11 04:36:03

您需要执行以下操作,以便

  • 通过 php 本机 ftp 命令传输 FLV
  • 在 ffmpeg 服务器中创建一个层来运行您的命令
  • 读取响应代码并执行特定操作

如果您通过 ftp 将文件发送到服务器,则 ,然后创建您刚刚将文件传输到的服务器上的脚本,您可以使用文件的哈希代码 ping 该脚本,并告诉它进行转换。

  • 通过 FTP 发送文件(上传示例
  • ping 服务器以启动

转换转换脚本将获取文件名,然后在本地目录中查找该文件,当找到该文件时,它将进行转换。

如果您希望本地服务器知道转换何时完成,那么您还必须向转换脚本发送一个 id,并且您将存储该 id 双方,以便服务器可以 ping 回您的本地脚本(警告!)以及 id,您可以从服务器取回它。

警告的原因是因为如果您位于路由器/防火墙后面,则很难让服务器 ping 到您的本地主机,您必须在路由器上设置端口转发等并允许从外部访问端口 80。< /em>

希望这能为您提供一些如何处理这种情况的线索。

You need to do the following in order

  • Transfer the FLV via php native ftp commands
  • Create a layer in the ffmpeg server to run your commands
  • Read the response code and perform a specific action

if you send your file to the server via ftp, and then create a script on the server that you have just transferred the file to, you can ping the script with the hash code for the file, and tell it to convert.

  • Sending file via FTP (Upload Example)
  • ping server to start the conversion

the conversion script would take a file name, and then look in the local directory for the file, when it finds it, it will convert.

if you wish for the local server to know when the conversion is completed then you would also have to send an id to the conversion script and you would store that id both sides, so the server can ping back to your local script (WARNING!) with the id and you can fetch it back from server.

The reason for the warning is because its hard to get a server to ping threw to your localhost if your behind a router / firewall you would have to set up port forwarding etc on router and allow port 80 to be accessed externally.

hope this gives you some clue on how to handle this situation.

江挽川 2024-10-11 04:36:03

编写一个 php 脚本并将其上传到您的 flv 转换服务器。
该脚本应该:

  1. 将 flv 文件(通过 POST 或其他下载方式)下载到 vid.flv
  2. 运行服务器命令“exec(ffmpeg -i vid.flv -acodec copy output.mp3);”
  3. 当output.mo3准备好时通知您结果

您可能需要更改脚本的最大执行时间(set_time_limit);

这样您的脚本就不需要通过 ssh 发送命令。

Write a php script and upload it to your flv conversion server.
The script should:

  1. Download the flv file (via POST or another way of download) into vid.flv
  2. Run the server command "exec(ffmpeg -i vid.flv -acodec copy output.mp3);"
  3. Notify you of results whe output.mo3 is ready

You many need to change max execution time of the script (set_time_limit);

This way your script would not need to send commands via ssh.

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