I couldn't find a tutorial on how to setup OSCam with TVH, let alone on a PI, so I made this tutorial.
The first thing you need to do is install OSCam, there are two versions; the regular/vanilla one and the OSCam-Emu fork. I opted for the former since there's a docker package that supports Arm64, you can emulate on the vanilla version too and this is the way this tutorial will cover.
To install OSCam this way you must install docker first, here's the commands I used on Raspberry PI OS Lite 64bit
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Now you can just pull any tag you want, I opted for the latest
sudo docker pull linuxserver/oscam:arm64v8-latest
On your home folder create a folder called oscam and inside it a file called docker-compose.yml that contains the following lines:
---
services:
oscam:
image: linuxserver/oscam:arm64v8-latest
container_name: oscam
network_mode: host
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Athens
volumes:
- ./config:/config
restart: unless-stopped
Obviously make any necessary changes like the timezone and if you are not on a Pi, the image you pulled.
On the same folder create another folder called config. Inside this config folder create the following files:
oscam.conf
[global]
logfile = stdout
[dvbapi]
enabled = 1
pmt_mode = 4
listen_port = 9000
user = tvheadend
boxtype = pc
[webif]
httpport = 8888
httpallowed = 0.0.0.0-255.255.255.255
oscam.server
[reader]
label = OSEmu
protocol = cs357x
device = 127.0.0.1,11000
user = osemu
password = osemu
caid = 0500,2600,FFFF
ident = 0500:000000,021110;2600:000000
group = 1
emmcache = 1,1,2,1
oscam.user
[account]
user = tvheadend
pwd = tvheadend
group = 1
au = 1
Just make sure you don't have another self hosted service running on these ports (8888, 9000, etc.)
As I mentioned above, regular OSCAM does not have emulation capabilities, meaning that we cannot decrypt channels without a physical smartcard. In order to be able to emulate on this version of OSCam we must run our own emulator, this is where OSEmu comes into play.
OSEmu must be compiled but it's pretty easy and fast, even on a PI, just run these commands
sudo apt install git
git clone https://github.com/oscam-emu/OSEmu.git
cd OSEmu/
make
Once make finishes you will have a binary named OSEmu.You must now move this to a common path so that systemd can start it as service
sudo install -m 755 -o root -g root OSEmu /usr/local/bin/OSEmu
Once that's done create a file called osemu.service on /etc/systemd/system/ containing the following (you can use sudo nano /etc/systemd/system/osemu.service)
[Unit]
Description=OSEmu Softcam Emulator
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/OSEmu -a osemu:osemu -p 11000 -b -c /var/keys -l /var/log/osemu.log
Restart=always
User=root
[Install]
WantedBy=multi-user.target
Also create a directory called keys on /var and create a file called SoftCam.Key (Linux is case sensitive) inside it, you will put your keys there in softcam format. I won't tell you where to find softcam key files but it's not hard.
Once that's done run sudo systemctl daemon-reload && sudo systemctl enable --now osemu to enable and start OSEmu as a service.
cd inside the oscam directory created in the previous step and run these two commands
sudo docker compose up -d --force-recreate
sudo docker compose restart
On TVHeadend, go to 🔧 Configuration > 🔑 CAs and click Add > Type: CAPMT (Linux Network DVBAPI) with default settings, just give it client name: oscam and enable it and you should get a green dot with a tick.
That's it, encrypted channels should play now if your keys are correct.