Aug 212013
 

Aka how to view YouTube videos on your Raspberry Pi from Midori or Chromium!

youtube-on-the-raspberry-pi

We have pulled together some software magic and are proud to announce an easy installation procedure for PiVid, the YouTube / HTML5 Video / VeeHD Raspberry Pi video enabler:

Installation

Open a shell – for instance LXTerminal, if you are working on the Raspberry Pi desktop, it can be opened by double-clicking the LXTerminal icon – and enter the following commands:

Step I: Please add our Repository

sudo wget -O /etc/apt/sources.list.d/repository.pi3g.com.list http://repository.pi3g.com/sources.list
sudo wget -O - http://repository.pi3g.com/pubkey | sudo apt-key add -
sudo aptitude update

This will:

  • set up our repository as an additional package source on your Raspberry Pi (your main sources.list will not be modified in any way)
  • get our public key
  • fetch the available packages from our repository server

Step II: Install PiVid

sudo aptitude install pivid

This will:

  • install PiVid and dependencies (other packages which PiVid requires to work)

Please press “Enter” when asked whether you want to continue, and once again “Enter” during the installation process of the youtube-dl package, when asked to.

Step III: Activate PiVid

service pivid start

This will:

  • start the pivid service (it talks to your browser and to omxplayer to play your video)

If you want to stop the pivid service, simply use “service pivid stop” – this will save a small amount of computing resources.

Step IV: Install PiVid in your browser

Install PiVid in Midori:

To use the userscript in Midori (Raspbians default browser), you have to activate the “User addons” extension. Start Midori. Open the preferences dialog (Menu>Preferences), select the Extensions tab and tick “User addons”. (“User addons” is the very last entry, use the scroll bar to find it). Click “Close”.

Then simply open the script ( file:///usr/share/pivid/replace.user.js ) in your browser (copy & paste the link into your URL bar, and press enter) and click “Install user script” when asked.

pivid-userscript-midori

 

Install PiVid in Chromium:

To install pivid in Chromium, please open a shell in the X desktop environment (e.g. LXTerminal), and start Chromium like this:

# chromium --enable-easy-off-store-extension-install /usr/share/pivid/replace.user.js

pivid-userscript-chromium

Please click “Continue”, and then click “Add” on the “Confirm New Extension” dialogue:

click-add

Chrome will confirm, that the extension has been added.

Usage

Please note: after every reboot, you need to start the pivid service, as described above. Open LXTerminal, and (as user pi), enter:

service pivid start

You can close LXTerminal after starting the service, if you want. If the service pivid is already running, it will tell you so – you don’t need to worry about entering it twice by accident.

Starting PiVid will open a web server on your Raspberry Pi’s port 3000. This will be accessible on your local network – and can be used to control video playback (of external URLs) on the Raspberry. This is by design, and we plan to release more documentation about this soon.

YouTube

youtube-raspberry-chromium

Navigate to a YouTube video (for example: Xcylin, shooting with a frickin’ laser). First, the browsers will display “Flash Player missing”, but after some seconds, the web site should reload, and display the PiVid play button, as seen above for Chromium.

Simply click this button, and the video should launch in a short while. This will be indicated by a “pause” button:

youtube-raspberry-c-pause

If you want to see the video again, please reload the page – PiVid currently can’t identify when the video has stopped playing.  The pause button currently has no function, but you can use omxplayer keyboard control (see below).

VeeHD

VeeHD is an alternative video hosting platform / community, sporting an interesting selection of movies, documentaries, etc.

PiVid supports playback on VeeHD. You may need to log in as a VeeHD user for some videos to work, and some videos are hosted on very slow servers – where streaming is impossible with PiVid. Please download the video and play it with omxplayer instead.

Usage: Search with the VeeHD search, and click on the video you would like to see. PiVid will show you the play button after a short while:

veehd-raspberry-pi

Omxplayer keyboard control

Space or p = Pause / Resume
– / + = Decrease / Increase Volume
q = Quit

 

Problem handling

YouTube play button not showing

If the PiVid play button does not show up on a YouTube video, instead of the warning about an incompatible browser, please try to simply reload the page – it should show up now.

Restarting the service

If you run into any unexpected problems using the software, try restarting the pivid service:

service pivid restart

If this does not help, try restarting your Raspberry, and starting the service after that. If still stuck, comment below. (Use “pivid” instead of “service pivid start” to see some advanced debugging output).

update-rc.d

Please note, that update-rc.d can’t be used right now to install the service as autostart on boot – we are investigating the cause and will release an update soon. (pivid service will start, but without video playback.) Please use the manual starting method ( service pivid start ) in the meantime – thank you!

Background

PiVid works as a server (written in the uber-cool Node.JS), which will display an IFRAME in your browser. Through a user script, the browser can submit the URL needed to retrieve and play the video. Once you click on the “play” button, PiVid will invoke some software incantations (sprinkle the equivalent of magic fairy dust – we’re building on the shoulders of giants – you guys know who you are :-) – and voilà – the video location will be passed to omxplayer, the trusty workhorse of Raspberry Pi video playback!

You can, of course, fork us on GitHUB.

By the way – we have also packaged a newer version of Node.JS to go along with PiVid on our repository – package name is “nodejs”. Stay tuned for more about this.

The idea for PiVid was taken from a very similar client-server approach, which was coded in Python, but seems to be abandoned now. Thank you for the inspiration!

Reference

  • Admiral

    In Midori the “Install User script” message does not appear.

    • pi3g

      ” you have to activate the “User addons” extension” – did you do that before trying to install the user script?

      If it still does not work, you can also add the user script manually – activate the sidebar of Midori, select the appropriate tab, and use the add user script button to select the user script (you can see the path in the screenshot).

      Please reply if this helped.

      • Admiral

        That’s it. Thanks. I had to activate the “User Addons” extension.

  • Pingback: Raspberry Pi ja missio | Lahtela.com()

  • Joseph Austin

    atttempt to access Youtube via Midori gives:Error – http://localhost:3000/playbutton.html?http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0QW9naTAbqA

    The page ‘http://localhost:3000/playbutton.html?http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0QW9naTAbqA’ couldn’t be loaded.

    Cannot connect to destination (localhost)
    ====
    $ service pivid start
    gave:

    [….] Starting PiVid: pivid/etc/init.d/pivid: 24: /etc/init.d/pivid: cannot create /var/log/pivid.log: Permission denied

    [ ok ady running.

    ====
    I must have done something wrong

    • pi3g

      Hello Joseph,

      try running pivid as root, when already logged into X Windows (e.g. from LXTerminal). Like this (as user pi):

      sudo service pivid start

      That being said, we are abandoning this project, and unfortunately can’t provide any further support.

      Merry Christmas :-)
      Max

  • Pal

    hello all, i’m now working on opening the youtube video as soon as my pi boots up, Right now midori is openning in full screen mode but the video is not being played on open instead i have to close the browser and open it again to play, it works fine at that time but i donno why it is not happening at the first place. i also have started pivid services as soon as it boots up but donno y it’s not working fine. Please help guys

  • Pal

    i have done using this code to play the video on booting of my pi board

    The Raspberry Pi configurator launches the first time you boot up and can be summoned at any time by opening a terminal window and typing in

    “sudo raspi-config”

    This allows you to simply select an option that boots the Pi into the graphical interface under the section “boot_behaviour”. After this a very small script must be written that will invoke the browser and point it at the desired website. Just open an editor at the command line and create a file called newstrt.sh in your home directory such as

    “nano /home/pi/newstrt.sh”

    In this file you need only two lines. The first tells the script where to call the command from and the second invokes midori in “Fullscreen” mode and goes to the URL you define.

    #!/usr/bin/sh

    midori -e Fullscreen -a http://www.youtube.com/watch?v=giVs8nPKHNA &

    After this make your script executable

    “sudo chmod +x /home/pi/newstrt.sh”

    and add your script to your LXDE autostart file

    “sudo nano /etc/xdg/lxsession/LXDE/autostart”

    Be sure to use sudo before trying to edit this file. At the bottom of the file add the line

    “@sh /home/pi/newstrt.sh”

    please help me out guys

    • pi3g

      Hello Pal,

      you should look into youtube-dl and omxplayer for downloading / streaming the video directly, without the browser – if all you are interested in is displaying one specific video.

      You might also look into Raspbmc et al, which have frontends to YouTube. Might suit your application better.

      Trying to run the browser in full screen with pivid is a very flaky solution, as there are focus issues, control issues. etc. I do not recommend this – pivid is meant for casual users of YouTube videos on the pi.

      As to automatically starting things – you’re on the right track.

      As we have abandoned this project I can’t provide any further support beyond this point. Good luck with your project!

      Max

      • Pal

        thanks MaX,

        I’m very new to this pi board. i’m using this board from past two days and i was given a small task to make any youtube video to be displayed as soon as booting so i was trying this. Your suggestion helped a lot. If you can tell me bit more about this will be helpfull max.

        cheers
        pal

        • pi3g

          Hello Pal,

          my suggestion would be to install the pivid package (as it installs all necessary dependencies) as per our instructions.

          Afterwards look at our source code (pivid is script based), which should explain to you how to interact with youtube downloader. This should help you to interact with youtube-dl and set up on-boot display of a video.

          Don’t start X, it is unnecessary for simply displaying the video – omxplayer runs from the command line. Research on the Internet for automatic login / start of a command – it’s been documented elsewhere.

          If your company (?) is interested in spending 1000 € daily rates, they are very welcome to delegate the task to our developers.

          Cheers and good luck,
          Max

          • Pal

            really helped Max,

            i’m now facing a different problem.I have opened the browser and youtube video file on boot and started the pivid services on boot itself, but the browser layout will show me missing plugin. If i close and open the browser, all the video will be played properly. I’m not getting what is it. can i close and open browser after boot so that this can solve my problem. I’m using midori.

            Regards and Happy New Year,
            Pal

          • pi3g

            This is a timing issue. As I said, I recommend playing the videos directly without the browser.

            If you want to, look in our JavaScript frontend code (which is injected in Midori) and try to tweak it.

            The missing plugin is shown by Midori, as it indeed does not have the plugin to play back the video. Our JavaScript code replaces the area in Midori with our IFRAME which builds the link / play button for the video. A bit of a kludge, really.

            Also a happy new year to you, and success with your project!
            Max

Optimization WordPress Plugins & Solutions by W3 EDGE