2009-05-15 149 views
2

使用的ffmpeg在远程机器上我有我的局域网在三台计算机上,我如何通过ssh

一个运行Ubuntu的
一个运行的openSUSE
和运行的Archlinux我的服务器。

我只设法让ffmpeg在我的服务器上正常工作。

我想编写一个脚本,会假装是本地计算机上的的ffmpeg安装,但实际上只是使用服务器的的ffmpeg

例子:

在openSUSE的PC我想呼吁:

ffmpeg -i file.avi out.flv

,然后得到正常的输出正如人们所期望的那样,
但我想它在archlinux上使用ffmpeg。

任何意见,如何我会得到这个工作。
(最好是用Ruby)

编辑:我已经扩展了这一问题How do I display progress bars from a shell command over ssh

回答

2

我没有很多的红宝石,但这似乎工作!

先决条件,

sudo yum install rubygems 
sudo gem install net-ssh net-sftp highline echoe 

代码(带注释),

#!/usr/bin/env ruby 

require 'rubygems' 
require 'net/ssh' 
require 'net/sftp' 
require 'highline/import' 

file = ARGV[ 0 ]     # filename from command line 
prod = file + "-new"    # product filename (call it <file>-new) 
rpath = "/tmp"     # remote computer operating directory 
rfile = "#{rpath}/#{file}"  # remote filename 
rprod = "#{rpath}/#{prod}"  # remote product 
cmd = "mv #{rfile} #{rprod}"  # remote command, constructed 

host = "-YOUR REMOTE HOST-" 
user = "-YOUR REMOTE USERNAME-" 
pass = ask("Password: ") { |q| q.echo = false } # password from stdin 

Net::SSH.start(host, user, :password => pass) do |ssh| 
     ssh.sftp.connect do |sftp| 
       # upload local 'file' to remote 'rfile' 
       sftp.upload!(file, rfile) 

       # run remote command 'cmd' to produce 'rprod' 
       ssh.exec!(cmd) 

       # download remote 'rprod' to local 'prod' 
       sftp.download!(rprod, prod) 
     end 
end 

,然后我可以运行这个像这样,

[email protected] ~/tmp/ruby) ls 
bar remotefoo.rb* 
[email protected] ~/tmp/ruby) ./remotefoo.rb bar 
Password: 
[email protected] ~/tmp/ruby) ls 
bar bar-new remotefoo.rb* 
2

这里有一些选择,最简单的第一:

  • 设置NFS您的局域网,远程的所有挂载您的服务器上的磁盘,然后使用远程装入的名称运行ssh命令。用户的负担是使用奇怪的名字。

  • 设置NFS,但解析ffmpeg选项以识别输入和输出文件,然后使用类似realname包(或简单的shell脚本)将名称首先转换为绝对路径名,然后转换为远程装入的名称。

  • 不要使用NFS,而是解析ffmpeg选项并使用scp将输入文件复制回输出文件。