HOWTO: Stream videos to Apple TV 2, using iPad under Ubuntu

Discussion in 'AirPlay' started by DrHouse, Apr 12, 2011.

  1. DrHouse
    Offline

    DrHouse iPad Junkie

    Joined:
    Jan 17, 2011
    Messages:
    644
    Thanks Received:
    21
    Trophy Points:
    0
    Location:
    Quebec
    Ratings:
    +21 / 0
    Playing around with my iPad/iPhone and Ubuntu, I got an idea that could help Ubuntu Users who have an Apple TV 2...

    The goal is to be able to stream any movie (mp4 format) from a local drive using the iPad/iPhone as the streamer to the Apple TV 2. First, I looked as a few free apps to see what was possible. In the end, I needed to download the movie on my device and then stream to the Apple TV 2. That's not what I wanted to do. I want the stream directly from the remote disk without having to download the file on my device.

    So I figured out that some websites allow AirPlay to be used on their website... After a few searches, I found out how to embed a video in a webpage, so it would be airplayable using the iOS device. Here is the basic HTML 5 code:

    Code:
    <video controls='true' width='120' height='80' x-webkit-airplay='allow' src='somemovie.mp4'></video>
    
    Next step was to create a webpage that would scan a folder, and embed all those movies into a HTML page...

    So to make it quick, I created a small bash script to do the job. Of course, PHP or other web language can be used to do the same job, but I wanted to do a fast proof of concept...

    Here is the script:

    Code:
    #!/bin/bash
    echo "<HTML>">index.html
    echo "<body>">>index.html
    echo "<H3>Movies List</h3>">>index.html
    for f in *.m4v; do
    echo "$f<br>">>index.html
    echo "<video controls='true' width='120' height='80' x-webkit-airplay='allow' src='$f'></video><br>">>index.html
    done
    echo "</body>">>index.html
    echo "</HTML>">>index.html
    
    You have to install Apache2 to have a webserver, and create a symlink in "/var/www/" that will point to your videos folder

    Code:
    sudo ln -s /home/patrick/Videos /var/www/videos
    
    Run the script in the folder of your videos so it will create a file called "index.html". Then, using your iDevice, goto "http://192.168.1.6/videos" (Put your own ip adress, of course!)

    The results will give you this (using my iPhone):

    [​IMG]

    Then just play any movie and activate AirPlay towards your Apple TV 2...

    This is a pretty basic script, but a lot more can be done. If you use some language like PHP, then you could scan dynamically for sub-folders, any supported media type, have more details about each movie, etc...

    So that means for Ubuntu fellows, iTunes is not needed anymore if you want to watch your local movies on your Apple TV 2!

    Have fun!

    Attached Files:

  2. DrHouse
    Offline

    DrHouse iPad Junkie

    Joined:
    Jan 17, 2011
    Messages:
    644
    Thanks Received:
    21
    Trophy Points:
    0
    Location:
    Quebec
    Ratings:
    +21 / 0
    AirPlay using pure HTML for Apache2 (or else)

    Ok, I've made some more tests using my Ubuntu Laptop, an external USB hardrive and, yep, movies...

    Since I was using an external hardrive, I had to give Apache2 my credentials so it could read my USB drive. Surely there is a better way, but, this is a proof of concept...

    I've modified the script to create a lighther index.html page since the iPad is trying to create a thumbnail of all movies. This was giving some bottle neck on the USB drive. To solve that issue, I created a webpage called "viewer.html" which takes as parameter "movie" making it easy to reuse for each movie. No PHP is needed since all is done in javascript.

    So basically, you run the script "updateFolder.sh" in the folder containing the movies (mp4/m4v). This will create a file "index.html". You have also to copy the "viewer.html" at the same location (Yes, I know, it could have been created automatically...).

    In Apache2, make sure that the symlink is pointing to your movie folder. So the URL http://192.168.1.6/movies will end up loading the index.html file.

    I used Apache2, but any webserver should work. Actually, it would even work in Windows with IIS but you would have to convert the script file to VBS or CMD file (Not just renaming it...)

    Then, with your Safari on the iPad, you load that webpage, and you will have a list of all your movies. Click on one of them, and the viewer.html will be loaded with the title you selected. Click "Play" and watch your movie on your iPad, or redirect using AirPlay.

    See attachements for the scripts and html files...

    Attached Files:

  3. HKWrite12
    Offline

    HKWrite12 iPad Addict

    Joined:
    Mar 19, 2011
    Messages:
    1,043
    Thanks Received:
    7
    Trophy Points:
    0
    Location:
    Oxford, MS
    Ratings:
    +7 / 0
    Noob ? What's ubuntu?
  4. DrHouse
    Offline

    DrHouse iPad Junkie

    Joined:
    Jan 17, 2011
    Messages:
    644
    Thanks Received:
    21
    Trophy Points:
    0
    Location:
    Quebec
    Ratings:
    +21 / 0
    Linux, a distribution of it. Like red hat or Debian...

    VicoPad addict!

Share This Page

Search tags for this page
airplay with ubuntu and apple tv
,
apple tv and ubuntu
,

apple tv ubuntu

,

linux stream to apple tv

,
mirror ubuntu to apple tv
,
mirroring from ubuntu to apple tv
,
stream from debian to ipad
,
stream from linux to appletev
,

stream from ubuntu to apple tv

,
stream video to apple tv linux
,
stream video ubuntu appletv
,
streama frã¥n ubuntu till apple tv
,
ubuntu airplay
,
ubuntu airplay to appletv
,

ubuntu apple tv

,
ubuntu apple tv 2
,

ubuntu appletv

,
ubuntu stream mp4 appletv
,

ubuntu stream to apple tv

,
ubuntu using apple tv