Remote Videos

I went to watch a movie that I had downloaded on an external hard drive connected to my older notebook.
Usually, I connect this hard drive directly to the TV, but this time I couldn’t eject the hard drive because it was being used by other programs.
So, I found myself in a situation with two alternatives: watch the movie on the 14" screen or find a way to stream the video to my new notebook, which has an HDMI output, and enjoy all the sound and image quality that LG™ provides.

As a good computer movie lover (I’m not), I chose the second option and will write here how I solved the problem at that time as well as other methods I discovered later.

1. Put the computers on a network

I didn’t have a router to set up a network. Since both notebooks have wireless cards, I created an Ad-Hoc network, as explained in this post (without the internet part).

2. Find a way to exchange files

There are several ways to send files from one computer to another on the network:

  1. SSH

    SSH was the first thing that came to mind because I’m used to it. I admit it’s not a very good solution, as it consumes a lot of CPU and unnecessarily increases network traffic (there’s no reason to use encryption unless you’re paranoid or the video is extremely confidential). Anyway, it worked well as follows:

    1. Install and activate SSH on both computers:

      sudo pacman -S openssh
      sudo /etc/rc.d/sshd start
      
    2. Connect Computer2 to Computer1 via ssh:

      ssh julio@192.168.1.1
      
    3. Play the video

      mplayer video.avi -display :0
      

      or

      export DISPLAY=:0
      

    in case we need to use another program that does not have a command to change the display.

  2. SSH with pipe

    As in the previous mode, but redirecting the video directly to mplayer

    ssh julio@192.168.1.2 "cat /media/external/Videos/video.avi" | mplayer -cache 65536 -
    
  3. SSHFS

    1. Install sshfs

      sudo pacman -S sshfs
      
    2. Mount the file system

      sshfs julio@192.168.1.2:/media/external /media/external
      
    3. Go to the folder and play the video with mplayer as if it were a local file.

      mplayer /media/external/Videos/video.avi
      
  4. SSH with X11

    1. Change, on the server, the file /etc/ssh/sshd_conf from

      #X11forwarding no
      

      to

      X11Forwarding yes
      

      or, on the client, edit /etc/ssh/ssh_config from #ForwardX11 no to ForwardX11 yes.

    2. Play the video with mplayer

      ssh -XY julio@192.168.1.2 mplayer /media/external/Videos/video.avi
      
  5. Samba

    1. Download Samba

    2. Enable sharing of your video folder

      #  vim /etc/samba/smb.conf
      [videos]
         comment = Videos do Julio
         path = /media/externo/Videos
         writable = no
         valid users = julio
         follow symlinks = yes
         wide links = yes
      
    3. Mount the file system

      sudo mount -t cifs //192.168.0.1/Videos /media/external/Videos -o user=julio,password=PASSWORD,workgroup=WORKGROUP
      
    4. Play the video with mplayer as if it were a local file

      mplayer /media/external/Videos/video.avi
      
  6. Netcat

    • On the computer with the video:

      cat /media/external/Videos/video.avi | nc -l -p 9998
      
    • On the computer connected to the TV:

      nc 192.168.0.1 9998 | mplayer -vo x11 -cache 3000 -
      
  7. VLC with sftp

    file » Open Network…

    sftp://julio@10.211.55.3/media/external/Videos/video.avi

    Enter login and password

3. Convert

At home network, I was able to stream 720p video without any issues, even with my old computer using old wi-fi (802.11g). However, if you want to do the same with 1080p video or even stream over the internet, it may be interesting to convert the video in real time. For that, you can use ffmpeg.

Avoid Standby

To prevent the computer monitor connected to the Television from turning off automatically due to inactivity, we can disable standby through Xorg:

sudo vim /etc/X11/xorg.conf

And leave the ServerLayout session as in the example below:

Section "ServerLayout"
        Identifier                  "Layout"
        Screen      0               "Screen0"
        Option      "Xinerama"      "true"
        Option      "BlankTime"     "0"
        Option      "StandbyTime"   "0"
        Option      "SuspendTime"   "0"
        Option      "OffTime"       "0"
EndSection

Julio Batista Silva
Julio Batista Silva
Data Engineer

I’m a computer engineer passionate about science, technology, photography, and languages. Currently working as a Data Engineer in Germany.

comments powered by Disqus