How to Stream Favorite Movies (MP4 Files) From Linux Terminal to Your Apple TV

If you are in search of a solution to stream your downloaded movie content to an Apple TV on your home network, you may have hit a barrier that many Linux users hit, which is that Apple hasn’t made it easy to tap into their AirPlay technology.

Stream Movies to Apple TV from Linux
Stream Movies to Apple TV from Linux

There is a way however, to take your .mp4 video files and stream them to your Apple TV, thanks to a few nifty Ruby programs and the libraries used by the Airplay protocol.

Assuming you are using Ubuntu (or any Ubuntu based distro) you will need to install the following dependencies required to communicate with your Apple TV device.

1. Open a terminal window and install the package “libavahi-compat-libdnssd-dev” by typing the following command.

$ sudo apt-get install libavahi-compat-libdnssd-dev
Install Libavahi Package
Install Libavahi Package

2. After that installation is complete make sure you have at least Ruby 2.0 installed on your system. Inside of your terminal type the following to ensure that it is indeed installed.

$ ruby --version

You will receive an output that should look something like this:

ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux]
Check Ruby Version
Check Ruby Version

If 1.9.x is installed, you will want to upgrade your version of Ruby to 2.x by adding the Ruby PPA to your apt sources list. You would do so by typing the following commands in your terminal.

$ sudo apt-add-repository ppa:brightbox/ruby-ng

When prompted hit ENTER. Next run,

$ sudo apt-get update
$ sudo apt-get install ruby2.0-dev
Add Ruby PPA
Add Ruby PPA
Update System
Update System
Install Ruby Package
Install Ruby Package

3. Now that Ruby is up to date, we will need to install two “gems” that will allow us to send our video to our Apple TV. The gems we will install are airplayer and airstream.

To install we will need to run the following:

$ sudo gem install airplayer
$ sudo gem install airstream
Install airplayer Package
Install airplayer Package
Install airstream Package
Install airstream Package

Note: This will automatically install the dependencies required to run these programs as well as the programs themselves.

4. We have the software we need to stream our video, but we need to know where on our network our Apple TV is (where to send our video). To do this we run,

$ airplayer devices

This command will output something that will resemble,

0: Apple TV (Resolution: 1280x720, Version: 200.54, IP: 192.168.0.6:7000)
Search airplay Devices
Search airplay Devices

Note: Take note of that IP address (minus the ‘:7000’) portion.

5. Now go the path, where your favorite movies stored and then in a terminal window run the following command to stream the movie to your Apple TV.

$ cd /path/where/video/is/
$ airstream -o IP.OF.APPLE.DEVICE ./nameofvideo.mp4
Play Movies to Apple TV
Play Movies to Apple TV

6. Now check out your TV and viola! You are streaming your video to your Apple TV.

Conclusion

Now, some knowledgeable on this subject may airplayer alone is sufficient to handle playback of video on Apple TV. It has been my experience that the airstream gem does this task more reliably. I simply use the airplayer gem to discover the IP address of the Apple TV.

If you have videos that are not in mp4 format and are .mkv, .avi, .mov, they will need to be converted in order for playback to work via airstream.

Feel free to post your questions, and I hope this will be a painless process to accessing what is rightfully yours.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Cameron Banowsky
I have been programming and using Linux for 3+ years, and find that often the toughest of problems yield the greatest of knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

12 Comments

Leave a Reply
  1. When the video is playing, in Terminal the progress bar is very incorrect – when the movie is 90% done it only shows 9%, so it is a ‘zero’ out – does anybody know how to fix this?

    Reply
  2. Great stuff, I had some problems until I installed ruby, ruby-dev, make, automake, gcc, g++ – not sure if all were strictly needed. What was needed on top was “apt-get install libavahi-compat-libdnssd-dev“.

    I managed to get mp3 playing via my Apple TV nicely. MP4 video shows picture and sound for a second or two and then crashes with an error. Anyone else got this – and maybe was able to fix it?

    loading can take a few seconds...
    => press [q] to exit airstream
    /var/lib/gems/2.3.0/gems/ruby-progressbar-
    1.1.1/lib/progress_bar/components/bar.rb:33:in `*': negative argument
    (ArgumentError)
            from /var/lib/gems/2.3.0/gems/ruby-progressbar-
    1.1.1/lib/progress_bar/components/bar.rb:33:in `empty_string'
    
    Reply
  3. Anyone having problems installing Airstream may want to follow this link ( https://github.com/unused/airstream )to the Airstream Github page. Scroll down to “troubleshooting” on that page and follow the promts.
    Though I had Ruby installed, I did not have Ruby Dev installed. I simply solved this by using the command
    sudo apt-get install ruby-dev . After I had this installed/working, I entered this command sudo apt-get install libavahi-compat-libdnssd-dev and then I was easilly able to install both gems, for airplayer and airstream by using these commands sudo gem install airplayer and sudo gem install airstream .

    Reply
  4. Got it to work. But for some reason, it often takes many attempts to get it to stream to the ATV. Sometimes the ATV complains “an error blah blah, the content cannot be streamed” and sometimes airstream stalls and nothing happens. Wonder why. Any clues ?

    Reply
    • In my experience files smaller than 1GB will run, but files larger than 1GB will give that error. That’s what I’ve deduced, but you could be experiencing something different. I just shrink my video sizes a bit and everything plays A-OK.

      Reply
  5. Can’t updare the Ruby, It shows this error when I try to run “sudo apt-get install ruby2.0-dev”

    E: Unable to locate package ruby2.0
    E: Couldn’t find any package by regex ‘ruby2.0’

    Reply
  6. Hi!

    Just finish to install, there is no ruby2.2-dev version so we have to stay il ruby2.1!

    I works fine but not for mkv files, do you have a solution to play directly those files?

    Reply
  7. Hello
    I appreciate your help regarding these settings on linux but I have a question;
    Is it possible to send music from spotify installed on linux to an airplay device like freebox player ?
    Thanks for your help y advance

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.