Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't control output sound from system volume control #18

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e304a49
Update Dockerfile
monkaBlyat Jul 27, 2020
1c2c4b1
Update README.md
monkaBlyat Jul 28, 2020
09973dd
Update README.md
monkaBlyat Jul 28, 2020
d4715f2
Update README.md
monkaBlyat Jul 28, 2020
46a4f98
Update README.md
monkaBlyat Jul 28, 2020
6279f98
Update README.md
monkaBlyat Jul 28, 2020
26e623c
Update README.md
monkaBlyat Jul 28, 2020
8b29ae3
Update README.md
monkaBlyat Jul 28, 2020
aa49200
Update README.md
monkaBlyat Jul 28, 2020
83bfcd9
Update README.md
monkaBlyat Jul 28, 2020
8d46973
Update README.md
monkaBlyat Jul 28, 2020
49aea89
Update Dockerfile
monkaBlyat Dec 7, 2020
0fc87e3
Update Dockerfile
monkaBlyat Dec 9, 2020
c8053d1
Add files via upload
monkaBlyat Dec 9, 2020
e91dbfc
Add files via upload
monkaBlyat Dec 9, 2020
5d49a16
Update chromium-armhf
monkaBlyat Dec 9, 2020
47b17d7
Update README.md
monkaBlyat Dec 10, 2020
b9ea526
Update README.md
monkaBlyat Dec 10, 2020
7e9464e
Update chromium-armhf
monkaBlyat Dec 10, 2020
f5d4306
Update README.md
monkaBlyat Dec 13, 2020
d68d355
Delete chromium.desktop
monkaBlyat Jan 22, 2021
802441f
Add files via upload
monkaBlyat Jan 22, 2021
192a1fd
Delete Chromium-Armv7.desktop
monkaBlyat Jan 22, 2021
c797fe0
Add files via upload
monkaBlyat Jan 22, 2021
4e585bd
Add files via upload
monkaBlyat Jan 22, 2021
ee576c2
Update Chromium-Armv7.desktop
monkaBlyat Jan 23, 2021
bfb35c0
Update Dockerfile
monkaBlyat Oct 10, 2021
986913b
Update Dockerfile
monkaBlyat Oct 10, 2021
33b112b
Update Dockerfile
monkaBlyat Nov 17, 2021
1272ffe
test
monkaBlyat Mar 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Chromium-Armv7.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=true
Exec=sudo /usr/local/bin/chromium-armhf
Name=Chromium Docker
GenericName=Web Browser
Comment=Browser for Netflix, Amazon and Spotify
Icon=/home/pi/.themes/chromium.jpg
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a relative path

Categories=Network;WebBrowser;
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM docker.io/arm32v7/debian:unstable
MAINTAINER Henning Thiemann <henning.thiemann@gmail.com>
FROM docker.io/arm32v7/ubuntu:bionic
MAINTAINER Furkan Kardame <furkan@fkardame.com>

# Install dependencies
ENV DEBIAN_FRONTEND noninteractive
Expand Down Expand Up @@ -31,6 +31,9 @@ RUN echo "Updating Chromium..." && dpkg -i chromium-codecs.deb && dpkg -i chromi
ADD widevine/libwidevinecdm.so /usr/lib/chromium-browser
ADD widevine/PepperFlash /usr/lib/chromium-browser/pepper

# Install Netflix 1080P Extension
ADD widevine/netflix-1080p-1.20.1 /usr/lib/chromium-browser/netflix-1080p

# Copy Pulseaudio config
COPY pulse-client.conf /etc/pulse/client.conf

Expand All @@ -48,5 +51,4 @@ RUN export UNAME=$UNAME UID=1000 GID=1000 && \
USER $UNAME
ENV HOME /home/${UNAME}

CMD ["/usr/bin/chromium-browser", "--user-agent='Mozilla/5.0 (X11; CrOS armv7l 6946.63.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'"]

CMD ["/usr/bin/chromium-browser", "--user-agent='Mozilla/5.0 (X11; CrOS armv7l 12607.82.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.123 Safari/537.36'"]
30 changes: 7 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Currently, it provides widevine CDM support.
## Build
To build the application, you have to clone it first,
```
git clone
sudo apt install docker docker.io pulseaudio-utils pulseaudio
git clone https://github.com/monkaBlyat/docker-chromium-armhf
cd docker-chromium-armhf
docker build -t hthiemann/chromium-armhf .
sudo docker build -t hthiemann/chromium-armhf .
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an anti-pattern to run docker via sudo. You should add your user to the docker-users group instead

https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user

```

## Run the container:
Expand All @@ -19,29 +20,12 @@ If the xhost command can not be found, make sure to install it first (on manjaro

Although not required, it is recommended to save chromium settings in a volume, to make it persistent through container restarts.
```
docker volume create chromium_home
sudo docker volume create chromium_home
```
After creating the volume, you can run the image using the following command:
```
docker pull hthiemann/docker-chromium-armhf

docker run --rm --privileged \
-e DISPLAY=unix$DISPLAY \
-v chromium_home:/home \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /dev:/dev -v /run:/run \
-v /etc/machine-id:/etc/machine-id \
--ipc=host \
--device /dev/dri \
--group-add video \
hthiemann/docker-chromium-armhf
```
Or simply use the script chromium-armhf:
```
sudo install -m 755 chromium-armhf /usr/local/bin
sudo docker pull hthiemann/docker-chromium-armhf
sudo cp chromium-armhf /usr/local/bin
sudo usermod -aG docker $(whoami)
chromium-armhf
```

## Known Bugs
- HW accelaration not working (check chrome://gpu)
- Settings Tab crashed directly after loading
5 changes: 5 additions & 0 deletions chromium-armhf
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

echo "Set host IP for Pulseaudio"
addrip="$(docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}')"

echo "Enabling XHost Forwarding"
xhost +local:docker

Expand All @@ -9,6 +12,8 @@ echo "Found and using ${DOCKER_IMAGE_ID}"

docker run --rm --privileged \
-e DISPLAY=unix$DISPLAY \
-e PULSE_SERVER=tcp:${addrip}:4713 \
-e PULSE_COOKIE_DATA=`pax11publish -d | grep --color=never -Po '(?<=^Cookie: ).*'` \
-v chromium_home:/home \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /dev:/dev -v /run:/run \
Expand Down
Binary file added chromium.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions widevine/netflix-1080p-1.20.1/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 truedread

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
70 changes: 70 additions & 0 deletions widevine/netflix-1080p-1.20.1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# netflix-1080p
Chrome extension to play Netflix in 1080p and 5.1

# How it works

The core of Netflix playback lies in JavaScript: specifically its "cadmium playercore" JS. The way Netflix (poorly) enforces 1080p to only be played back on ChromeOS devices is through these lines of JavaScript:

```javascript
a = /CrOS/.test(a.userAgent);
this.Fma = this.Aw = q.Gu.PV;
this.Qm = [x.$l.nV];
this.oo = [x.V.vA, x.V.wA];
a && this.oo.push(x.V.TH);
```

What it is doing is testing your User-agent for the "CrOS" string anywhere in it. If the search returns true, it appends the 1080p profile to the profile playback array (what this line `a && this.oo.push(x.V.TH);` is doing). If it returns false, it does nothing. The playback profile array is set up like so: `this.oo = [x.V.vA, x.V.wA];`, x.V.vA is the SD profile and x.V.wA is the 720p profile.

After reading this you think the easy solution would be to just change the User-agent to make it contain the string "CrOS" right? Not that simple. ChromeOS apparently has a different DRM implementation than chrome, even though both use Widevine. I could never get it to work when I tried, Netflix always threw license errors. The next easiest thing to do is just delete the conditional to append 1080p and just make the 1080p profile apart of the regular profiles (`this.oo = [x.V.vA, x.V.wA];` -> `this.oo = [x.V.vA, x.V.wA, x.V.TH];`). This works perfectly, but only for the majority of Netflix content. A few videos, like Disney movies, have manifests completely restricted to Edge to the point where you can't obtain them without an Edge ESN.

So, the next problem is how do you get an Edge manifest within Chrome? That's what I attempted to do with `get_manifest.js`, which is a Netflix MSL client written entirely in JavaScript (essentially my [pymsl](https://github.com/truedread/pymsl) library ported to JS). Of course there already an MSL client in JavaScript: the playercore. But since it's so heavily obfuscated, it was easier to rewrite one myself. The new mod has this snippet of code:

```javascript
var f = c.HS.viewables[0];
if (/watch/.test(window.location.pathname)) {
var edgeLocked = true;

for (var i = 0; i < f.videoTracks[0].downloadables.length; i++) {
if (f.videoTracks[0].downloadables[i].contentProfile == "playready-h264mpl40-dash") {
edgeLocked = false;
break;
}
}

if (edgeLocked) {
console.log("Manifest locked to Edge (or not available in 1080p)");
console.log("Getting Edge manifest");
var manifest = await getManifest();
console.log("Acquisition successful, commence playback");
var edge_manifest = manifest.result.viewables[0];
edge_manifest.playbackContextId = f.playbackContextId;
edge_manifest.drmContextId = f.drmContextId;
f = edge_manifest;
}
}
```

What this new snippet of code does is test if the current page is a /watch/ URL, and if so check the Chrome manifest to see if a 1080p profile is already included. If so, commence playback like normal. If not, call `getManifest()` from `get_manifest.js` and replace the `playbackContextId` and `drmContextId` from the Edge manifest with values from the Chrome manifest. This is for license acquisition: those values are for the MSL server to maintain a persistent session between manifest acquisition and license acquisition. If you use an Edge `playbackContextId` and `drmContextId`, you'll be unable to obtain a Widevine license for Chrome. After all those operations are performed, playback is resumed like normal.

All the Chrome extension has to do is redirect all requests to Netflix's playercore to the modified one it has in the root directory. ~~That's it. A two line modification.~~ What was once a two line modification has turned into a giant project to cover all the bases in 1080p playback.

# Why?

Why not.

# Notes

- Chrome Webstore link: https://chrome.google.com/webstore/detail/netflix-1080p/cankofcoohmbhfpcemhmaaeennfbnmgp
- This may raise your CPU usage since Netflix was never intended to be played back in 1080p on Chrome. See [this](https://github.com/truedread/netflix-1080p/issues/15#issuecomment-398256248) comment for more details.
- Make sure to clear your browser cache, as the cached playercore will override the modified one and you will not be able to play 1080p.
- On videos where Edge manifest acquisition is needed (the console will say so), initial loading may take 5 seconds longer due to two manifests needing to be obtained.

# Donate

I'm still a student, so if you could help me out and buy me a cup of coffee it would support my future projects and development on this extension! Please note that donating is completely optional; this extension is free and will remain free forever.

- BTC: 1CqGMe6skpNQGSmm7uEtSrVfAUo59fYBnM
- ETH: 0x87053e321B3a4b94c6c38e6A062bF91649285452
- Ko-fi: https://ko-fi.com/truedread

Thanks!
12 changes: 12 additions & 0 deletions widevine/netflix-1080p-1.20.1/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
return {
redirectUrl: chrome.extension.getURL("cadmium-playercore-6.0023.327.011-1080p.js")
};
}, {
urls: [
"*://assets.nflxext.com/*/ffe/player/html/*",
"*://www.assets.nflxext.com/*/ffe/player/html/*"
]
}, ["blocking"]
);
Loading