Skip to content

Instantly share code, notes, and snippets.

@jesstelford
Last active April 4, 2020 17:52
Show Gist options
  • Save jesstelford/eded5fe8c2611f332648 to your computer and use it in GitHub Desktop.
Save jesstelford/eded5fe8c2611f332648 to your computer and use it in GitHub Desktop.
Netflix on Raspberry Pi (incomplete)

Note: as @clibois mentioned below, due to the DRM Netflix uses, all decoding has to be done in CPU, making it somewhat choppy.

Note 2: Even the RPi 3 suffers from these CPU limitations. There is the potentially risky option of overclocking your RPi 3, but I haven't tried this.

If you manage to get smooth playback, please contact me, or post your solution here

UPDATE: I can no longer get this method to work. I have tried using Chromium v47, and v48, and both result in Netflix error "Oops, something went wrong" / C7053-1807, for which I can find no description online. If you manage to get things up and running, please contact me!

OSMC

These steps are based on OSMC, which in turn is based on a Debian Jessie + Kodi install, so should be the same for any Debian based setup.

For the quickest setup, install the latest OSMC

Preparation

Create a working folder

We'll use this directory to store our temporary downloads, etc.

mkdir netflix
cd netflix

Update the RPi

Note: for all the commands below, I suggest switching into Super User mode to avoid typing sudo before every command:

sudo su

Let's start by making sure everything is up to date:

apt-get update
apt-get upgrade

Chromium

This section is inspired by the instructions here

We need to grab Chromium v47 - v48 has a bug with netflix, and v49+ doesn't work on our Debian Jessie system.

  1. Visit the page for chromium-browser
  2. Scroll down to "The Vivid Vervet" and click that heading.
  3. Scroll down to the "Releases in Ubuntu" heading
  4. Find the highest version that starts with 47 (note: v48 does not work).
  5. Click the arrow next to it.
  6. Look for the Builds header on the right
  7. Click the "armhf" option.
  8. On the following page, scroll to the bottom to find the list of links under Built Files.

For each of the files that look like:

  • chromium-browser_*.deb
  • chromium-codecs-ffmpeg-extra_*.deb

(Note: You do not need the *-dbg*.deb or *-chromedriver*.deb versions of the packages)

For example, I grabbed these files:

We need to download them on the RPi:

wget -c https://launchpad.net/...

Next, install the ffmpeg deb with:

dpkg -i chromium-codecs*.deb

Now, install the dependencies:

apt-get install `dpkg -I chromium-browser*.deb | grep " Depends" | sed "s/^ Depends: //" | sed "s/ ([^)]\+)//g" | sed "s/ | [^ ]\+//g" | sed "s/,//g"`

This command essentially searches for the dependencies of the chromium-browser*.deb package, then installs them all.

Gotchyas

but it is not going to be installed

If you get any errors such as:

avr-libc : Depends: gcc-avr (>= 1:4.3.4) but it is not going to be installed

Then you need to run the following commands (This will fix all the broken dependencies, and re-configure all the previously broken packages.):

apt-get clean
apt-get install -f
dpkg --configure -a

Then re-run command above to install the dependencies.

libexif / lsb-release not installed

I also had to install libexif12 & lsb-release to get chromium running:

apt-get install libexif12 lsb-release

Now, install chromium:

dpkg -i chromium-browser*.deb

Set chromium to run correctly; edit the file /etc/chromium-browser/default to be (You can use vi or nano to edit the file):

CHROMIUM_FLAGS="-password-store=detect -user-data-dir"

Finally, setup a symlink so plugins, etc, that are searching for chrome will find chromium instead:

cd /usr/bin
ln -s chromium-browser chrome-browser
ln -s chromium-browser chrome
cd -

Audio

In order to have Chrome output its audio to HDMI, we need to setup the ALSA drivers:

apt-get install alsa-utils
modprobe snd_bcm2835
amixer cset numid=3 2

(the 2 at the end is to specify HDMI. Use 1 for headphones)

Window Manager

For Chrome to take advantage of the full screen, and to use the mouse, we need a window environment of some kind. Since OSMC doesn't come with one by default, let's install matchbox now:

apt-get install xorg xinit matchbox

Launching Chromium

If you're still root (because you ran sudo su as mentioned at the top), drop to your normal user now:

exit

Create a new file /home/osmc/.xinitrc (using vi or nano) with the contents:

#!/bin/bash
# ~/.xinitrc

xset -dpms
xset s off
xset s noblank

matchbox-window-manager &
chromium-browser http://www.netflix.com

kill $!

Make it executable with:

chmod a+x /home/osmc/.xinitrc

And now give permission to start up the script by editing the file /etc/X11/Xwrapper.config (may require being root again), and changing the allowed_users line to be:

allowed_users=anybody

Then to test, ensure you can see OSMC up and running on whatever display you have the rPi connected to, make sure you're not root, then run the following command:

sudo systemctl stop mediacenter && xinit /home/osmc/.xinitrc && sudo systemctl start mediacenter

This will shut-down OSMC and pop up Chromium. To go back to OSMC, use the Chromium shortcut to close the current window: <ctrl>-w (or if you have a mouse, simply click the "x" to close the window).

Note: The first time you run the above command it may display a black screen for 30-60 seconds before displaying Chromium. Subsequent executions should show Chromium within 1-2 seconds of OSMC shutting down.

Note: If you see errors such as [1:1:0326/155000:ERROR:image_metadata_extractor.cc(112)] Couldn't load libexif., then you can install the missing dependency like so:

sudo apt-get install libexif12

Playing Netflix in Chromium

Netflix requires libnss3 (already installed as a dependency of chromium-*.deb above), and the widevine DRM plugin.

Prior to Chromium v44, widevine would only work with official Google Chrome (which doesn't work on the RPi's ARM-based CPU). However, from 44 onwards, a patch has been added to allow the widevine plugin to work.

Getting widevine working

Thanks to @ who managed to get it working!

Obtain widevine plugin

Thanks to Google's ARM ChromeOS builds, we can get a working copy of the widevine plugin to run on our RPi.

Still on the RPi:

wget https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_7077.134.0_daisy-skate_recovery_stable-channel_skate-mp.bin.zip
unzip chromeos*.zip

Then we want to get access to the files stored on that ChromeOS image:

sudo apt-get install kpartx
sudo kpartx -avs chromeos*.bin

You will see the following output where it has created a series of partitions, representing the Chromebook disk image:

add map loop0p1 (254:0): 0 28672 linear /dev/loop0 2928640
add map loop0p2 (254:1): 0 32768 linear /dev/loop0 20480
add map loop0p3 (254:2): 0 2641920 linear /dev/loop0 286720
add map ...

We're interested in the one ending in p3, which will now exist at /dev/mapper/loop0p3. Let's mount it:

sudo mkdir -p /media/osmc/chromeos
sudo mount -t ext2 /dev/mapper/loop0p3 -o ro /media/osmc/chromeos/

Now move into the root of that partition and search for the widevine plugins:

cd /media/osmc/chromeos/
find ./ -type f -name "libwidevine*"

The two files you want are named libwidevinecdm.so and libwidevinecdmadapter.so (ignore any "Permission denied" errors).

sudo cp <path_to_files>/libwidevine*.so /usr/lib/chromium-browser/

(replace <path_to_files> with the location returned from the find command above)

Controlling Chromium

Before we continue, we need a way to control Chromium. Let's do it with our phone!

Grab the app Home Remote Control.

Install xdotool on the RPi:

apt-get install xdotool

In Home Remote Control, select "Linux only" and enter your RPi's IP address, as well as the user / pass combo to log into SSH (default is: osmc/osmc).

Tricking Netflix into executing widevine

Fire up Chromium again:

sudo systemctl stop mediacenter && xinit /home/osmc/.xinitrc && sudo systemctl start mediacenter

Once Chromium is loaded up, install the "User Agent Switcher" extension from the Play Store, then add the following user agent as "Chrome":

Mozilla/5.0 (X11; CrOS armv7l 6946.63.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36

In the "User Agent Switcher" tool, set that as a permanent override for netflix.com.

Reload netflix.com, and you should now be able to start streaming!

Cleaning up

Shutdown your RPi:

sudo shutdown now

Then start it up again (this is a cheat's way of unmounting the ChromeOS image).

SSH back into your RPi, then remove the temporary folder we created at the start:

sudo rm -rf /home/osmc/netflix
@buma
Copy link

buma commented May 12, 2016

I was also successful with latest version of chromium (49) from https://www.raspberrypi.org/forums/viewtopic.php?t=121195 and this image: https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_7834.60.0_daisy_recovery_stable-channel_snow-mp-v3.bin.zip .

Netflix playback was really smooth. CPU and GPU is at 70°C. But during Netflix GUI it is at 75°C. When I disabled top panel in Netflix and used EGLS --use-gl=egl temperature dropped. Seems that GL ES is used for changing the size of posters on hover in Netflix UI since everything is smoother with this. But I have only SD Netflix package so video is much easier to decode.

Netflix worked only when started with different user agent:

chromium-browser --use-gl=egl --user-agent=”Mozilla/5.0 (X11; CrOS armv7l 6946.86.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36”

Those urls are useful when testing DRM:
Open https://shaka-player-demo.appspot.com/ and load a manifest that uses Widevine.
Open http://www.dash-player.com/demo/drm-test-area/, check whether the page says bitdash uses Widevine in your browser, then play the video.

Both worked and showed Widevine even before changing user agent but Netflix worked only with different user agent.

Usefull is also list of Chrome flags: http://peter.sh/experiments/chromium-command-line-switches/

@carneiru
Copy link

carneiru commented May 16, 2016

Someone could make a "dd " sdcard backup with a funtional Netflix and share? I don't know why these steps don't work for me, I'm using kodi instead osmc...

@silberzwiebel
Copy link

silberzwiebel commented May 23, 2016

Thanks for this tutorial. I was succesful to play netflix under OSMC in chromium with this and the chromium versions and libwidevine libraries mentioned in the comments from @buma and @mboel.
However, I do want to use netflix from within kodi and tried to use the flix2kodi addon that @clibois mentioned. To do so, I also installed lxde. Unfortunately, I am not able to switch to the chromium that flix2kodi succefully starts. That is, I hear the sound but do not see the video. Chromium is running, but Kodi stays on top of the display. I tried to plug in a keyboard and do an alt-tab, but this does not work. Apparently, kodi always runs in a fullscreen mode. All the workaround to get windowed mode of kodi do not work. If anybody has a hint to do this, I'd be very grateful.
I'm happy to provide a tutorial then, too.

@jolny
Copy link

jolny commented May 29, 2016

@silberzwiebel maybe you can find it by going through the screen sessions? Not sure if it'd work with Kodi, but in Ubuntu you can use Ctrl-Alt-F3 to get into a terminal. Or possibly Alt + -> (arrow key). If it works, you could check if you can find another screen session which contains Chromium.

@thetrueavatar
Copy link

thetrueavatar commented Jun 13, 2016

@silberzwiebel : I didn't succeed to mamakde it work but one hint for you is that I think that kodi with osmc doesn't use any X11 server. So what you see on the screen isn't something rendered by the X server. That would explain why you hear the sound but doesn't see the video. Don't know how to fix that though...

@fitiko
Copy link

fitiko commented Jul 10, 2016

Try with the v51 version of chromium. It might work according to this topic:

https://www.raspberrypi.org/forums/viewtopic.php?f=35&t=98559&sid=a5712aa35fbbbfad38594733ebb3df04&start=50

@hackwilleeuw
Copy link

hackwilleeuw commented Jul 12, 2016

Guide works 50% for me on osmc / ubuntu mate
1 problem.. video is all garbage.

& this is my first post on github.

@facundobianco
Copy link

facundobianco commented Aug 14, 2016

Following @fitiko's comment I installed the v51 version (from The Trusty Thar):

wget https://launchpad.net/ubuntu/+archive/primary/+files/chromium-browser_51.0.2704.79-0ubuntu0.14.04.1.1121_armhf.deb
wget https://launchpad.net/ubuntu/+archive/primary/+files/chromium-codecs-ffmpeg-extra_51.0.2704.79-0ubuntu0.14.04.1.1121_armhf.deb
wget http://ftp.us.debian.org/debian/pool/main/libg/libgcrypt11/libgcrypt11_1.5.0-5+deb7u4_armhf.deb
sudo apt-get install --no-install-recommends gconf-service libasound2 libatk1.0-0 libatomic1 libc6 libcairo2 \
    libcups2 libdbus-1-3 libexpat1 libfontconfig1 libfreetype6 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
    libgtk2.0-0 libnspr4 libnss3 libpam0g libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libstdc++6 \
    libx11-6 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \
    libxtst6 zlib1g bash libnss3 xdg-utils libc6 libgcc1 zlib1g python-crypto
for NDEB in libgcrypt11_1.5.0-5+deb7u4_armhf.deb \
    ffmpeg-extra_51.0.2704.79-0ubuntu0.14.04.1.1121_armhf.deb \
    browser_51.0.2704.79-0ubuntu0.14.04.1.1121_armhf.deb
do sudo dpkg -i ${NDEB} ; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment