Skip to main content

Play youtube videos on Raspbian using omxplayer

This is a follow up post to the original one made by Jojen on setting raspbian to use omxplayer to play videos embedded in webpages. This yields much smoother playback on raspberry PI as omxplayer is built to use the PI GPU rather than software emulation.

BTW, some blog posts might suggest that you can install gnash and its browser plugin, but since it's not hardware accelerated, I found it's performance to be simply non-acceptable. So if you stumble upon those posts, you might as well save yourself some time and not go down that path.

Back to Jojen's post. Everything in the post works as it says it would, including playing the sample video the link to which he has at the bottom of his post. The trouble starts when you try to play youtube videos. I found this was due to two reasons:

  1. Incorrect permissions on the script
  2. Midory user addon Javascript failing to detect video links since youtube as has changed the relevant div tag id

The problems can be fixed thus:

  1. Change the permissions on omxplayer-youtuble-sh (located in /opt/media-berry/server) through the command: chmod 755
  2. Update the replace_video_user.js (located in ~/.local/share/midori/scripts) such that "#watch7-video" is replaced with "#player-api" in line 61(at the time of writing this post).

If it all worked, you should see the youtube video thumbnail being replaced with a rectangle with a play button in the middle.

There's a caveat. After playing the main video, if you try to visit one of the related clips through the links on the sidebar at the right, the video that you just played will be played. This probably has to do with Javascript variable lifetime in the user script. I haven’t had the time to look into it, but when and if I do I’ll post the updated script.