Streaming media between two linux boxes

I was wondering why it wasn’t possible to playback a movie over a ssh connection using remote X11 forwarding and mplayer. It seems that the latency is simply just too high. I’m not exactly sure if it’s a ssh or a X problem. This was on a wireless link, which might be part of the problem. While researching the problem I found this pretty cool patch for openssh that should give better transfer speeds. It’s in gentoo as the hpn use flag (even a patch for openssh 5.2). Sadly it did not seem to solve the problem. The movie was still very laggy. Then I tried adding a -C to add compression. This help a bit, but it was still painfully slow and uses quite a bit more cpu on the server side. Also the sounds will come out on the server end, so this might not work very well if you’re not in the same machine as the server 🙂

Back to the drawing board it seems… I found this excellent post on how to stream movies from a server to a Nokia 800 tablet with size conversion done on the fly at the server end. This script is pretty clever and truly UNIX style. It uses netcat to pipe the data from the server to the client, and just sticks a ffmpeg in front to scale the movie first. What is perfect about this solution is that it uses very little cpu (very good for small devices like the Nokia tablets) and it streams the sound to the client. The only downside seems to be that the data is not encrypted. But of course there are ways around that too if you really care.

On the client (mine is do this:

nc -l -p 5000 | mplayer –

And on the server side to this:

cat /movies/nice-movie.avi | nc 5000