远程ftp登录并将flv转换为mp3?
我试图找出通过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您无法通过 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.
查看 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.
您需要执行以下操作,以便
如果您通过 ftp 将文件发送到服务器,则 ,然后创建您刚刚将文件传输到的服务器上的脚本,您可以使用文件的哈希代码 ping 该脚本,并告诉它进行转换。
转换转换脚本将获取文件名,然后在本地目录中查找该文件,当找到该文件时,它将进行转换。
如果您希望本地服务器知道转换何时完成,那么您还必须向转换脚本发送一个 id,并且您将存储该 id 双方,以便服务器可以 ping 回您的本地脚本(警告!)以及 id,您可以从服务器取回它。
警告的原因是因为如果您位于路由器/防火墙后面,则很难让服务器 ping 到您的本地主机,您必须在路由器上设置端口转发等并允许从外部访问端口 80。< /em>
希望这能为您提供一些如何处理这种情况的线索。
You need to do the following in order
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.
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.
编写一个 php 脚本并将其上传到您的 flv 转换服务器。
该脚本应该:
您可能需要更改脚本的最大执行时间(set_time_limit);
这样您的脚本就不需要通过 ssh 发送命令。
Write a php script and upload it to your flv conversion server.
The script should:
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.