tags:

views:

623

answers:

2

I have three computers on my LAN,

one running ubuntu,
one running openSuse
and my server running Archlinux.

I've only managed to get ffmpeg to work properly on my server.

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.

Example:

on the openSuse pc i would like to call:

ffmpeg -i file.avi out.flv

and then get the normal output as one would expect,
but I want it to use the ffmpeg on the archlinux.

any advice as to how I would get this to work.
( preferably in Ruby )

EDIT: I've extended this question to http://stackoverflow.com/questions/872380

+2  A: 

Here are some options, easiest first:

  • Set up NFS on your LAN, remoted mount all disks on your server, then run an ssh command using the remote mounted names. The burden is on the user to use the strange names.

  • Set up NFS, but parse ffmpeg options to identify input and output files, then use something like the realname package (or a simple shell script) to convert the names first to absolute pathnames, then to the remote mounted names.

  • Don't use NFS, but parse ffmpeg options and use scp to copy the input files over and the output files back.

Norman Ramsey
+2  A: 

I don't have a lot of ruby-fu, but this seems to work!

Prerequisites,

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

Code (with comments),

#!/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

And then I can run this like so,

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*
Dylan