BETA: Chrome Capture for Channels

I'm trying to install CC4C using Docker on Windows 10. This is what I'm getting. Any idea what I'm doing wrong?

2024-02-20 16:04:52 [2024/02/20 21:04:52.602] Chrome Capture server listening on port 5589
2024-02-20 16:04:52 _XSERVTransmkdir: Owner of /tmp/.X11-unix should be set to root
2024-02-20 16:05:47 [2024/02/20 21:05:47.900] streaming https://www.nbc.com/live?brand=rsn-boston&callsign=nbcsboston
2024-02-20 16:06:32 [2024/02/20 21:06:32.870] GET /stream/nbcsboston from ::ffff:172.17.0.1 responded 200 in 717.811 ms
2024-02-20 16:06:32 [2024/02/20 21:06:32.899] finished https://www.nbc.com/live?brand=rsn-boston&callsign=nbcsboston
2024-02-20 16:06:32 [2024/02/20 21:06:32.903] failed to stream https://www.nbc.com/live?brand=rsn-boston&callsign=nbcsboston TargetCloseError: Waiting for selector video failed: Protocol error (Runtime.callFunctionOn): Target closed
2024-02-20 16:06:32 at CallbackRegistry.clear (/home/chrome/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:153:36)
2024-02-20 16:06:32 at CDPSessionImpl._onClosed (/home/chrome/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:468:70)
2024-02-20 16:06:32 at Connection.onMessage (/home/chrome/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:265:25)
2024-02-20 16:06:32 at WebSocket. (/home/chrome/node_modules/puppeteer-core/lib/cjs/puppeteer/common/NodeWebSocketTransport.js:62:32)
2024-02-20 16:06:32 at callListener (/home/chrome/node_modules/ws/lib/event-target.js:290:14)
2024-02-20 16:06:32 at WebSocket.onMessage (/home/chrome/node_modules/ws/lib/event-target.js:209:9)
2024-02-20 16:06:32 at WebSocket.emit (node:events:513:28)
2024-02-20 16:06:32 at Receiver.receiverOnMessage (/home/chrome/node_modules/ws/lib/websocket.js:1184:20)
2024-02-20 16:06:32 at Receiver.emit (node:events:513:28)
2024-02-20 16:06:32 at Receiver.dataMessage (/home/chrome/node_modules/ws/lib/receiver.js:541:14)

Does anyone know if this project is still being maintained as it appears that it hasnā€™t been updated in 8 months. It no longer works for me with YTTV as I canā€™t get past the login with NBC and get a unsupported browser errorā€¦

I can build you an updated container if you like -- amd64 only.

I would greatly appreciate that :grinning:. Does it need to be rebuilt every time there is a Chrome update?

Thanks so much!

Updated container built, and available at bnhf/cc4c:test. Use the following docker-compose to spin it up:

version: '3.9'
services:
  cc4c:
    image: bnhf/cc4c:${TAG}
    container_name: cc4c
    ports:
      - ${HOST_PORT}:5589 # cc4channels proxy port
      - ${HOST_VNC_PORT}:5900 # VNC port for entering credentials
    environment:
      - VIDEO=${VIDEO} # Desired video bit rate in bps. E.G., 9500000bps = 9500Kbps = 9.5Mbps
      - AUDIO=${AUDIO} # Desired audio bit rate in bps. E.G., 192000bps = 192Kbps
      - TZ=${TZ} # Add your timezone in the Environment variables section with "name" set to TZ and "value" to your local timezone
    shm_size: '1gb'
    volumes:
      - cc4c:/home/chrome # Creates persistent Docker Volume in /var/lib/docker/volumes for Chrome data and main.js
    restart: unless-stopped
volumes:
  cc4c:
    name: ${HOST_VOLUME}
TAG=test
HOST_PORT=5589
HOST_VNC_PORT=5900
VIDEO=9500000
AUDIO=192000
TZ=US/Mountain
HOST_VOLUME=cc4c_config

Did some very basic testing, and I was able to login to the streaming site via VNC (along with making the image fullscreen), and watch the channel in the Channels web player.

I'd suggest deleting any existing cc4c Docker-Volumes you have hanging around, before starting this new container.

shm_size: '1gb' is an untested addition, so feel free to comment it out if you're having issues. A Firefox container I use for another project has that setting, which I believe is an effort to be sure the container has sufficient resources.

Best way to get rid of existing cc4c Docker-Volumes is here in Portainer:

1 Like

Is this Docker for Linux only as I thought it would run under macOS ARM?

What Mac model (and year) are you trying to run it on?

1 Like

M2 Mac Mini (2024)

Is that the same machine you used last year with the fancybits container? I'm not too sure there's ever been an arm64 container version of this project:

This is the version pushed 8 months ago, and as you can see it's amd64 only. I can build arm64 no problem, but there's no Dockerfile for it in the repo:

FROM node:lts-bullseye AS base

RUN apt-get update \
	&& apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget x11vnc x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable x11-apps xvfb

RUN apt-get update \
    && apt-get install -y wget gnupg \
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update \
    && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 --no-install-recommends

WORKDIR /home/chrome
RUN groupadd -r chrome && useradd -r -g chrome -G audio,video chrome
COPY main.js package.json yarn.lock /home/chrome
RUN chown -R chrome:chrome /home/chrome
USER chrome

FROM base
RUN npm install
EXPOSE 5589
ENV DISPLAY :99
ENV CHROME_BIN /usr/bin/google-chrome
ENV DOCKER true
CMD Xvfb :99 -screen 0 1920x1080x16 & node main.js

Note where the Chrome package above is amd64. I don't think there is a packaged version of Chrome for arm64 Linux (which is what such a container would be using) -- Chromium yes, but not Chrome.

Will this work in Docker for Windows?

Running containers on a Windows machine makes use of the Windows Subsystem for Linux (WSL2). This can have a Windows frontend via Docker Desktop for Windows, but the backend would be WSL2. You can run pretty much any Docker container this way.

I was really just a bit worried about this variable; "/var/lib/docker/volumes". Thanks.

No, my old Mac was an Intel. I guess Iā€™m screwed. Thanks for the info. Maybe someone will create an Apple silicon versionā€¦

1 Like

Fair point, the location where a Docker Volume is stored does vary by how (and where) you've installed Docker. If you install Docker directly in a WSL distro, /var/lib/docker/volumes should be the location.

However, Docker Desktop is different when it comes to Docker volumes. Practically speaking, you're pretty much limited to managing them through the Desktop GUI:

The actual file location of a Volume is well obscured with Desktop.

I could try building it with Chromium -- but I have no idea if it would work. What about using the arm64 binary?

I tried that, unfortunately when I tried to authenticate with YTTV, it fails with an error message regarding the browser not being supported.

Think the shm_size change could help with the 12 hour failures?

1 Like

Seems at least like a possibility. The container is fully up-to-date, and I've incorporated the video and audio bitrate environment variables into the code -- so use the latest docker-compose posted above. Set the bitrate as low as you're able without seriously compromising the video quality. I'd imagine you could set the shm_size higher too, if your system can spare the memory.

This is such a big thread, I am hoping someone might be able to give me an answer (so I don't have to read 1400 comments).

Is it possible to adjust the bitrate of the Chrome Capture for the video and audio? I read somewhere about the audio not sounding too great unless you update the bitrate. Is there a way to do this, and if so, where is the change made?

Also, is hardware encoding used, and does it support an Intel Arc GPU for that?

1 Like

You can adjust the bitrate for audio and video in the main.js file. After this, you can run the new main.js file, or you'd have to compile it back into a new exe. Not sure how you're running CC4C?

I don't know about Intel Arc GPU's. But, I'd assume if Chrome can utilize that hardware, it's possible it would be used for CC4C, as well?

1 Like