Manage cookies

We use cookies to improve our services. Read more about how we use cookies and how you can refuse them.

The necessary cookies help to make the website work properly.

Anonymous statistical cookies help to understand how visitors use the website.

  • Raspberry Pi
    3 min | 72696

    #Raspberry Pi: Amazon Prime, Netflix, etc. and a DRM solution!

    Raspberry Pi | 3 min | 72696


    It is a rainy day and you have a Raspberry Pi, which is running Raspberry OS (Raspbian), and you think: I can make a media center to watch some movies/series. You configure everything, and then you see something like the next picture, every time that you want to watch Amazon Prime, Netflix, etc. using the Chromium Web Browser:

    Update 2021.04.05: Installing the Widevine DRM package to the Raspberry Pi is a straightforward process, follow the instructions from this tutorial: Raspberry Pi: Amazon Prime, Netflix, Disney, Spotify - a DRM official solution
    Fig. 1: Trying to play Amazon Prime videos on the Raspberry Pi running Raspberry OS.

    You could install Kodi, LibreElec or OSMC, and you'll be able to watch your series or movie without any problem (using some plugins). But, if you still want to use Raspberry OS (Raspbian), I can tell you: There is a solution! This means, your Raspberry Pi can still be a media center running Raspberry OS.

    But first, let me explain the error. This simply happens because of Digital Rights Management (DRM). The Chromium browser on the Raspberry OS doesn't support DRM. However, Chromium supports DRM using Widevine on Chrome OS running on ARM processors. This means, you could flash Chrome OS or Android on the Raspberry Pi, but they are not stable as I would like.

    Update 2020.11.15: I've just updated the solution and now it is working with Chromium >=84.0.4147.141. Earlier browser versions should use an old version of the gist file. To know which version of Chromium you are using, just type /usr/lib/chromium-browser/chromium-browser --version in a Terminal.

    If you want to update your OS, just type the following (after you've saved your important data)
    
    sudo apt-get update
    sudo apt-get upgrade
    

    DRM solution

    Therefore, the solution is to extract the library Widevine (libwidevinecdm.so) from ChromeOS and add it to Raspberry Pi OS. That sounds quite complex, right? But, it isn't at all! To do that, I found this script widevine-flash_armhf.sh, that fetches the latest official recovery image of ChromeOS for ARM, mounts it as a disk, and extracts the Widevine and Flash libraries, saving them in a compressed archive. You won't need the Flash library, but it is also available. The script is used for Vivaldi 2.0. Therefore, I forked and modified it for Chromium.

    Unsupported Browser
    Fig. 2: Unsupported Browser for DRM.
    Supported Browser
    Fig. 3: Supported Browser for DRM (user-agent changed).

    Furthermore, the websites, which need DRM, usually check the user-agent from the browser. The agent Chromium X on Linux is not supported (actually, it is blocked) (Fig. 2). However, Chromium allows you to change the agent by using the argument --user-agent. Therefore, the modified script creates a new file chromium-drm-browser.desktop using the file chromium-browser.desktop and adds the following line to the Exec=chromium-browser:

    --user-agent="Mozilla/5.0 (X11; CrOS armv7l 11895.95.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"

    and you'll get Fig. 3, when you add that line. The good news is that that browser is supported. :)

    You can check here for the last version of the browsers, and modify the script.

    DIY Instructions

    To add DRM support to Chromium on Raspberry OS, follow these steps:

    1. Download the script on the Raspberry Pi (you could use SSH):

      # Raspberry Pi OS (32bits) / Raspbian
      # check your Chromium version typing:
      /usr/lib/chromium-browser/chromium-browser --version
      
      # for new version of Chromium (>=84)
      wget https://gist.githubusercontent.com/lemariva/0eb4ff4e847700627a5ebb71711c31bf/raw/94314cb2d3c7da7518b220b2785f7bbd69671394/widevine-flash_armhf.sh
      
      # for older version of Chromium (<84) 
      wget https://gist.githubusercontent.com/lemariva/0eb4ff4e847700627a5ebb71711c31bf/raw/499f63eabc823ab564dc08e234ca7397a33bf717/widevine-flash_armhf.sh
      
    2. Change the file type to executable, typing:
      # 32 bits
      chmod +x widevine-flash_armhf.sh
    3. Run the script file, typing:
      # 32 bits
      sudo ./widevine-flash_armhf.sh

      The script needs sudo because it mounts the ChromeOS recovery image as a disk to extract the required files.Then, it copies the library Widevine under /usr/lib/chromium-browser/. It also creates and moves the chromium-drm-browser.desktop file to the /usr/share/applications folder. This folder is where the menu access is located.
      Update 20201115: Then, it creates two folders ${HOME}/.config/chromium-browser/WidevineCdm and /opt/WidevineCdm/_platform_specific/linux_arm. Inside the folder ${HOME}/.config/chromium-browser/WidevineCdm, it writes a file latest-component-updated-widevine-cdm with the location of the library. It moves the manifest.json inside the folder /opt/WidevineCdm, and finally inside /opt/WidevineCdm/_platform_specific/linux_arm, it moves the libwidevinecdm.so file.

      Important: You'll need about +2GB of free space on the microSD to download the recovery image of ChromeOS. After the required files are extracted, the image is deleted, and you get the space back.

    After doing that, you will get two direct accesses to the Chromium Web Browser (see Fig. 4). The Chromium (DRM) Web Browser has

    • Update 20201115: The standard browser shortcut will have DRM support and you can use it to play videos from Netflix, Hulu, HBO, Disney+, Amazon Prime, Spotify, Pandora, and many others (see Fig. 5). You need to close everything and open it again, or just reboot the Rasbperry Pi to be sure.
    • Update 20201206: Some users report that the user-agent modification is needed to play videos under Netflix. I've included the creation of the direct access again.
    Chromium (DRM) Web Browser
    Fig. 4: Direct accesses to Chromium with and without DRM support.
    Supported Browser
    Fig. 5: Playing videos on Amazon Prime
    using Chromium on the Raspberry Pi OS.
    Supported Browser
    Fig. 6: Playing music on Spotify
    using Chromium on the Raspberry Pi OS.

    Hardware Acceleration (Video Decoder)

    Check this article for more information:

    Extra information

    This section is intended for those who want to analyze the script. Google lists the recovery images of ChromeOS in this file:

    https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf

    and the selected recovery images are:

    Update: DRM doesn't work with Raspberry Pi OS 64bits. As described here, the Chromium-OS devices use a 32bits (arm) user ABI (Application Binary Interface). On Raspberry Pi OS, the user ABI is 64bits (aarch64), thus the compiled libraries don't load and you'll get following error: `wrong ELF class: ELFCLASS32` while starting Chromium.

    Common Errors / Problems

    Missing HDMI sound

    TomH has posted the following comment and this can be really helpful:

    Missing HDMI sound might be caused by one of the last OS updates. Pls see the screenshot below chapter "PulseAudio" at https://www.raspberrypi.org/blog/new-raspberry-pi-os-release-december-2020/
    After that update "AV Jack" was selected for me. While so easy to fix, it took me quite a while to have HDMI sound back


    Comments

    Empty