bhyve Invidious Youtube front end working in a Ubuntu Bhyve vm with Podman

I have managed to get Invidious working in a Ubuntu Bhyve vm with Podman

Invidious is an open source alternative front-end to YouTube.

Are you fed up with Youtube showing you rubbish
and just want to see the channels you have subscribed too

The Invidious urls work with mpv
and you can view the site using Emacs as well

Invidious set up notes after the screen shot



github notes


20250129_22h45m02s_grim.png



vm-bhyve setup

Code:
doas pkg install bhyve-firmware grub2-bhyve edk2-bhyve vm-bhyve-devel

zfs dataset

Code:
doas zfs create -o mountpoint=/vm zroot/vm
doas zfs create -o mountpoint=/vm/.iso zroot/vm/iso
doas zfs create -o mountpoint=/vm/.templates zroot/vm/templates

rc.conf

Code:
doas sysrc kld_list+="vmm nmdm"
doas sysrc vm_enable=YES
doas sysrc vm_dir="zfs:zroot/vm"

kldload

only needed if you havent rebooted, and not needed after that

Code:
doas kldload vmm nmdm

networking

gateway enable

Code:
doas sysrc gateway_enable=YES

sysctl

Code:
doas sysctl net.link.tap.up_on_open=1
doas sysctl net.inet.ip.forwarding=1

set option permanently

Code:
doas echo "net.link.tap.up_on_open=1" >> /etc/sysctl.conf
doas echo "net.inet.ip.forwarding=1" >> /etc/sysctl.conf

copy vm-bhyve config

Code:
doas cp -a /usr/local/share/examples/vm-bhyve /vm/.templates

doas

my doas config


Code:
sudo pkg install doas

edit doas.conf and add a rule for the vm command

Code:
doas vi /usr/local/etc/doas.conf

change username to your username

Code:
# vm-bhyve
permit nopass :username cmd vm

vm-bhyve start

service vm start

Code:
doas service vm start

only needed once if you havent rebooted


vm init

Code:
doas vm init

more networking

replace laggo with your network device

Code:
doas vm switch create public
doas vm switch add public lagg0

vm-bhyve create

fetch iso

i found the vm iso command stopped downloading the iso part way through,
so instead i used fetch to download the iso

Ubuntu 24.04 download with fetch

Code:
doas fetch -o /vm/.iso/ubuntu-24.04.1-live-server-amd64.iso 'https://releases.ubuntu.com/24.04.1/ubuntu-24.04.1-live-server-amd64.iso'

find number of cpu's

find the number of cpu's on Freebsd

Code:
sysctl kern.sched.topology_spec

vm config

create the invidious.conf for the bhyve vm

Code:
doas vi /vm/.templates/invidious.conf

Code:
loader="grub"
cpu=4
memory=4G
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="disk0.img"
grub_run_partition="2"
grub_run_dir="/grub"

vm create

Code:
doas vm create -t invidious -s 60G invidious

-t template name
-s file size of the vm


vm install

use the -f option to run the vm in the current terminal

Code:
doas vm install -f invidious ubuntu-24.04.1-live-server-amd64.iso

Ubuntu

Podman install

Code:
sudo apt install git podman podman-compose pwgen

youtube-trusted-session-generator


Code:
podman run quay.io/invidious/youtube-trusted-session-generator

copy the tokens output in the terminal you will need them later

clone the invidious repository

Code:
git clone https://github.com/iv-org/invidious.git

change directory in the invidious repository

Code:
cd invidious

edit docker-compose.yml

Code:
vi docker-compose.yml

set vi paste

Code:
:set paste

paste in the following


Code:
version: "3"
services:

  invidious:
    image: quay.io/invidious/invidious:latest
    # image: quay.io/invidious/invidious:latest-arm64 # ARM64/AArch64 devices
    restart: unless-stopped
    ports:
      - "127.0.0.1:3000:3000"
    environment:
      # Please read the following file for a comprehensive list of all available
      # configuration options and their associated syntax:
      # https://github.com/iv-org/invidious/blob/master/config/config.example.yml
      INVIDIOUS_CONFIG: |
        db:
          dbname: invidious
          user: kemal
          password: kemal
          host: invidious-db
          port: 5432
        check_tables: true
        signature_server: inv_sig_helper:12999
        visitor_data: CHANGE_ME
        po_token: CHANGE_ME
        # external_port:
        # domain:
        # https_only: false
        # statistics_enabled: false
        hmac_key: "CHANGE_ME!!"
    healthcheck:
      test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/trending || exit 1
      interval: 30s
      timeout: 5s
      retries: 2
    logging:
      options:
        max-size: "1G"
        max-file: "4"
    depends_on:
      - invidious-db

  inv_sig_helper:
    image: quay.io/invidious/inv-sig-helper:latest
    init: true
    command: ["--tcp", "0.0.0.0:12999"]
    environment:
      - RUST_LOG=info
    restart: unless-stopped
    cap_drop:
      - ALL
    read_only: true
    security_opt:
      - no-new-privileges:true

  invidious-db:
    image: docker.io/library/postgres:14
    restart: unless-stopped
    volumes:
      - postgresdata:/var/lib/postgresql/data
      - ./config/sql:/config/sql
      - ./docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh
    environment:
      POSTGRES_DB: invidious
      POSTGRES_USER: kemal
      POSTGRES_PASSWORD: kemal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]

volumes:
  postgresdata:

change the ip address

find the lan address of the vm

Code:
ip a

change the following section from 127.0.0.1


Code:
    ports:
      - "127.0.0.1:3000:3000"

to the vm lan ip

Code:
    ports:
      - "192.168.1.151:3000:3000"

change the following options

Code:
        hmac_key: "CHANGE_ME!!"
        visitor_data: CHANGE_ME
        po_token: CHANGE_ME

add the visitor_data and po_token you created earlier with the youtube-trusted-session-generator

You must set a random generated value for the parameter hmac_key:!
On Linux you can generate it using the command

Code:
pwgen 20 1

pwgen output

Code:
Ees6vou2IekaipeiCeib

Code:
        hmac_key: Ees6vou2IekaipeiCeib

turn of paste mode in vi

Code:
:set nopaste

podman-compose

make sure you are in the invidious git repository and run podman-compose up

Code:
podman-compose up

login

open your browser to the address of invidious

for example


select login and add a user name and password

on the next screen you have to complete a captcha
by adding the time shown in the clock


invidious vm start

how to start invidious in the future

Code:
doas vm start invidious

console

Code:
doas vm console invidious

press return and enter your username and password


start invidious

change directory into the invidious git repository

Code:
podman-compose up

stop invidious

looks like there is a bug using podman-compose down
or docker-compose down

which doesnt stop one of the container

so just control c to stop invidious

update invidious

change directory into the invidious git repository

Code:
podman-compose pull
podman-compose up -d
podman image prune -f

vm destroy

Code:
doas vm stop invidious
doas vm destroy invidious

alternative method

Code:
ls /dev/vmm

Code:
crw-------  1 root wheel 0x202 29 Jan 19:41 invidious

Code:
doas bhyvectl --vm=invidious --destroy

Note it is reccomended to restart Invidious every day or after an hour so

Screen shots

20250129_22h45m19s_grim.png



20250129_22h45m29s_grim.png


20250129_22h45m57s_grim.png
 
Last edited:
mpv conditional profile for Invidious url

Code:
vi ~/.config/mpv/mpv.conf

change 192.168.1.151 to the ip address of the invidious vm

Code:
# mpv.conf

# list profiles with: mpv --profile=help

# load hwdec profile automatically
profile=hwdec

# hardware acceleration profile
[hwdec]
profile-desc="hardware acceleration, no cache, yt-dlp 1080 or less"
vo=gpu
hwdec=vaapi

msg-level=ffmpeg=fatal

# cache no for internet streams
cache=no

# yt-dlp best format 1080 or less
ytdl-format="bestvideo[height<=?1080]+bestaudio/best"

# show milliseconds in the on screen display
osd-fractions

# youtube subs - J to switch to subs
sub-auto=fuzzy
ytdl-raw-options=sub-lang="en",write-sub=,write-auto-sub=
sub-font='NotoColorEmoji'

# screenshot timecode
screenshot-template="%F-[%P]v%#01n"

# invidious conditional auto profile match any invidious url
[invidious]
profile-desc="invidious hardware acceleration, cache"
profile-cond=path:find('http://192.168.1.151:3000') ~= nil
# include hwdec profile
profile=hwdec
# override hwdec profile cache setting
cache=no
# fullscreen 2nd display
fs
fs-screen-name=DP-3

# cache profile: mpv --profile=cache
[cache]
profile-desc="hardware acceleration, cache, yt-dlp 1080 or less"
# include hwdec profile
profile=hwdec
# override hwdec profile cache setting
cache=auto
 

Hardware requirements​

Running Invidious requires at least 20GB disk space, 512MB of free RAM (so ~2G installed on the system), as long as it is restarted regularly, as recommended in the post-install configuration.

Public instances should ideally have at least 60G disk space, 4GB of RAM, 2vCPU, a 200 mbps link and 20TB of traffic (no data cap/unlimited traffic is preferred).

Compiling Invidious requires at least 2.5GB of free RAM (We recommend to have at least 4GB installed). If you have less (e.g on a cheap VPS) you can setup a SWAP file or partition, so the combined amount is >= 4GB.

You need at least 1GB of RAM for the machine that will run the tool youtube-trusted-session-generator in the 1st step. Doesn't need to be the same machine as the one running Invidious, just a machine running on the same public IP address.


I set the vm to use 4 gig of ram and be 60 gig in size
 
Invidious opened using eww in Emacs

Emacs config
which has functions to play videos in eww with mpv


20250130_00h13m10s_grim.png



20250130_00h13m32s_grim.png



freebsd root dotfiles


freebsd dotfiles

 
Back
Top