问题描述
我的LAN上有三台电脑,
I have three computers on my LAN,
一个运行ubuntu ,
一个运行 openSuse
和我的服务器运行Archlinux 。
one running ubuntu,
one running openSuse
and my server running Archlinux.
我只设法得到 ffmpeg 在我的服务器上正常工作。
I've only managed to get ffmpeg to work properly on my server.
我想编写一个脚本,假装是一个 ffmpeg 安装本地机器,但实际上只是使用服务器的 ffmpeg 。
I would like to write a script that would pretend to be an ffmpeg installation on the local machine, but would actually just be using the server's ffmpeg.
示例:
ffmpeg -i file.avi out.flv
然后按照预期的方式获取正常输出,
但我想要在archlinux上使用ffmpeg。
and then get the normal output as one would expect,
but I want it to use the ffmpeg on the archlinux.
有关我如何让这个工作的任何建议。
(最好在Ruby中)
any advice as to how I would get this to work.
( preferably in Ruby )
编辑:我把这个问题扩展到了
I've extended this question to How do I display progress bars from a shell command over ssh
推荐答案
我没有很多红宝石,但这似乎很有效!
I don't have a lot of ruby-fu, but this seems to work!
先决条件,
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
然后我可以这样运行,
dylan@home ~/tmp/ruby) ls
bar remotefoo.rb*
dylan@home ~/tmp/ruby) ./remotefoo.rb bar
Password:
dylan@home ~/tmp/ruby) ls
bar bar-new remotefoo.rb*
这篇关于如何通过ssh在远程机器上使用ffmpeg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!