Building a Media Server
Building a Media Server
A while back I was on the hunt for a media server solution… these are running notes about 2 years old as of now (2/2021).
Handling video playback and copying DVD content to my digital storage.
This was interesting but looked a bit old. Dunno much about how old nux-desktop-release-0-5 is.
yum -y install http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
yum -y install
yum install ffmpeg HandBrake-cli
Could make a totally custom build of Handbrake on the latest Fedora, which is what Handbrake’s website suggests.
Followed these instructions to create a base container image
Then these instruction to create a custom build of latest Handbrake from source:
Create a Dockerfile from the basics of this article.
dnf install https://download0.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download0.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf install handbrake
handbrake vs makemkv
-
makemkv will rip without loss
Media server search
Started with PMS, Plex Media Server. What a terrible acronym. Let’s just call it Plex. I got this working from its official Docker image with a little work, to run using rootless containers with Podman instead of Docker. But I found out this requires a login to authorize and synchronize machine access. Bleh. How awful. The whole point of running my own software is that I control it without any phone home to another third party organization. Plex is dumped. I know how to manage my networking, and I don’t care about UPNP.
Then I checked out Emby, as others recommended after finding the auth requirement for Plex. It has a Tizen app for Samsung TVs so looks promising. But on first load of my test ISO, it failed to play properly. No ISO support. Ok, so that is asking a lot I suppose, but it’s a lot of work for me to convert hundreds of DVD ISOs to mp4 or mkv.
Then I checked out Kodi, which appears to be the first for many to select. I didn’t care much for the fact that they did not build their own container images. Linuxserver.io however builds one, and it worked fairly well I think. But I never figured out how to get the headless kodi instance to scan any particular folders for media. Maybe it was the web browser interface, Chorus. After 20 minutes of searching the web for answers and clicking around in the interface, I decided this idea was dead. Kodi apparently supports ISO, which is a huge plus for me, but it does not have a Tizen native app.
So back to Emby. It looks as though I’ll be building a process to convert all my ISO images to mp4.
Notes on container builds.
How to set up Macvlan Network with Podman - https://access.redhat.com/solutions/3898801
Running rootless Podman as a non-root user - https://www.redhat.com/sysadmin/rootless-podman-makes-sense
Podman and user namespaces: A marriage made in heaven - https://opensource.com/article/18/12/podman-and-user-namespaces
How does rootless Podman work? - https://opensource.com/article/19/2/how-does-rootless-podman-work
Why can’t rootless Podman pull my image? - https://www.redhat.com/sysadmin/rootless-podman
fatal: unable to exec run: Permission denied - https://github.com/linuxserver/docker-nzbget/issues/64
-
For future readers (as this was high up in the search results): this is a conflict between s6-overlay and podman, triggered by the name of the entrypoint (init).
-
Set
--systemd=false
to prevent the mounting behaviour that causes this conflict. (Source)
https://github.com/containers/libpod/issues/3803#issuecomment-520925279
man podman run
...
--systemd=true|false
Run container in systemd mode. The default is true.
If the command you running inside of the container is systemd or init, podman will setup tmpfs mount points in the following directories:
/run, /run/lock, /tmp, /sys/fs/cgroup/systemd, /var/lib/journal
It will also set the default stop signal to SIGRTMIN+3.
This allow systemd to run in a confined container without any modifications.
Note: On SELinux systems, systemd attempts to write to the cgroup file system. Containers writing to the cgroup file system are denied by default. The container_manage_cgroup boolean must be enabled for this to be allowed
on an SELinux separated system.
setsebool -P container_manage_cgroup true
podman system migrate
is useful sometimes upgrading from older Podman configs to newer ones.
error creating libpod runtime: there might not be enough IDs available in the namespace - https://github.com/containers/libpod/issues/3421
$ podman pull plexinc/pms-docker
Trying to pull registry.access.redhat.com/plexinc/pms-docker...ERRO[0000] Error pulling image ref //registry.access.redhat.com/plexinc/pms-docker:latest: Error initializing source docker://registry.access.redhat.com/plexinc/pms-docker:latest: Error reading manifest latest in registry.access.redhat.com/plexinc/pms-docker: name unknown: Repo not found
Failed
Trying to pull docker.io/plexinc/pms-docker...Getting image source signatures
Copying blob 996ae761782e done
Copying blob 716d454e56b6 done
Copying blob 19197c550755 done
Copying blob cc899a5544da done
Copying blob 0a01a72a686c done
Copying blob 5702041563a7 done
Copying blob ae8227024d17 done
Copying config f84c2bd8e6 done
Writing manifest to image destination
Storing signatures
ERRO[0019] Error while applying layer: ApplyLayer exit status 1 stdout: stderr: there might not be enough IDs available in the namespace (requested 0:42 for /etc/gshadow): lchown /etc/gshadow: invalid argument
ERRO[0019] Error pulling image ref //plexinc/pms-docker:latest: Error committing the finished image: error adding layer with blob "sha256:0a01a72a686c389637334de1e2d0012da298960366f6d8f358b8e10dc3b5e330": ApplyLayer exit status 1 stdout: stderr: there might not be enough IDs available in the namespace (requested 0:42 for /etc/gshadow): lchown /etc/gshadow: invalid argument
Failed
Trying to pull registry.fedoraproject.org/plexinc/pms-docker...ERRO[0020] Error pulling image ref //registry.fedoraproject.org/plexinc/pms-docker:latest: Error initializing source docker://registry.fedoraproject.org/plexinc/pms-docker:latest: Error reading manifest latest in registry.fedoraproject.org/plexinc/pms-docker: manifest unknown: manifest unknown
Failed
Trying to pull quay.io/plexinc/pms-docker...ERRO[0020] Error pulling image ref //quay.io/plexinc/pms-docker:latest: Error initializing source docker://quay.io/plexinc/pms-docker:latest: Error reading manifest latest in quay.io/plexinc/pms-docker: unauthorized: access to the requested resource is not authorized
Failed
Trying to pull registry.centos.org/plexinc/pms-docker...ERRO[0020] Error pulling image ref //registry.centos.org/plexinc/pms-docker:latest: Error initializing source docker://registry.centos.org/plexinc/pms-docker:latest: Error reading manifest latest in registry.centos.org/plexinc/pms-docker: manifest unknown: manifest unknown
Failed
Error: error pulling image "plexinc/pms-docker": unable to pull plexinc/pms-docker: 5 errors occurred:
* Error initializing source docker://registry.access.redhat.com/plexinc/pms-docker:latest: Error reading manifest latest in registry.access.redhat.com/plexinc/pms-docker: name unknown: Repo not found
* Error committing the finished image: error adding layer with blob "sha256:0a01a72a686c389637334de1e2d0012da298960366f6d8f358b8e10dc3b5e330": ApplyLayer exit status 1 stdout: stderr: there might not be enough IDs available in the namespace (requested 0:42 for /etc/gshadow): lchown /etc/gshadow: invalid argument
* Error initializing source docker://registry.fedoraproject.org/plexinc/pms-docker:latest: Error reading manifest latest in registry.fedoraproject.org/plexinc/pms-docker: manifest unknown: manifest unknown
* Error initializing source docker://quay.io/plexinc/pms-docker:latest: Error reading manifest latest in quay.io/plexinc/pms-docker: unauthorized: access to the requested resource is not authorized
* Error initializing source docker://registry.centos.org/plexinc/pms-docker:latest: Error reading manifest latest in registry.centos.org/plexinc/pms-docker: manifest unknown: manifest unknown
The above is a podman thing. We gotta set up our system to handle rootless. The first go I ran this on an upgraded RHEL 7 box and had to tweak some things. RHEL 8 and Fedora have this stuff set up default now.
sudo sysctl user.max_user_namespaces=15000 sudo vi /etc/subuid sudo vi /etc/subgid
makemkv containerized
Unable to execute external program 'ccextractor' as its path is not set in preferences
Failed to execute external program 'ccextractor' from location '/opt/makemkv/bin/mmccextr'
LIBMKV_TRACE: Exception: Error while reading input
Failed to save title 0 to file /output//title_t00.mkv
Unable to execute external program 'ccextractor' as its path is not set in preferences
Failed to execute external program 'ccextractor' from location '/opt/makemkv/bin/mmccextr'
LIBMKV_TRACE: Exception: Error while reading input
Failed to save title 1 to file /output//title_t01.mkv
Unable to execute external program 'ccextractor' as its path is not set in preferences
Failed to execute external program 'ccextractor' from location '/opt/makemkv/bin/mmccextr'
LIBMKV_TRACE: Exception: Error while reading input
Failed to save title 2 to file /output//title_t02.mkv
A few tweaks to run it in a container:
# ln -s /usr/bin/ccextractor /opt/makemkv/bin/mmccextr # ls -lah /opt/makemkv/bin/mmccextr lrwxrwxrwx 1 root root 20 Feb 11 02:06 /opt/makemkv/bin/mmccextr -> /usr/bin/ccextractor
example run:
/opt/makemkv/bin # makemkvcon mkv iso:/storage/X-Men.iso all /output
MakeMKV v1.14.7 linux(x64-release) started
The program can't find any usable optical drives.
Using direct disc access mode
Title #1 was added (60 cell(s), 1:43:47)
Cells 15-end were skipped due to cell commands (structure protection?)
Title #2 was added (13 cell(s), 0:27:07)
Cells 23-end were skipped due to cell commands (structure protection?)
Title #2/0/1 was added (3 cell(s), 0:06:36)
Cells 33-end were skipped due to cell commands (structure protection?)
Title #2/0/2 was added (5 cell(s), 0:11:18)
Cells 45-end were skipped due to cell commands (structure protection?)
Title #2/0/3 was added (9 cell(s), 0:17:00)
Title #2/0/4 was added (14 cell(s), 0:31:51)
Title #3 was added (5 cell(s), 0:21:57)
Title #4 has length of 31 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #5 has length of 31 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #6 has length of 32 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #7 was added (1 cell(s), 0:02:05)
Title #8 was added (1 cell(s), 0:02:29)
Title #9 has length of 51 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #10 has length of 62 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #11 has length of 117 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #12 has length of 101 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #13 has length of 32 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #14 has length of 95 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #15 has length of 27 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #16 has length of 110 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #17 has length of 94 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #18 was added (1 cell(s), 0:02:19)
Title #19 has length of 100 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #20 was added (1 cell(s), 0:03:13)
Title #21 was added (1 cell(s), 0:02:34)
Title #22 has length of 22 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #23 has length of 34 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #24 has length of 34 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #25 has length of 16 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #26 has length of 74 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #27 has length of 34 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #28 has length of 5 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #29 has length of 8 seconds which is less than minimum title length of 120 seconds and was therefore skipped
Title #30 was added (1 cell(s), 0:02:21)
Operation successfully completed
Saving 13 titles into directory /output
File /output/title_t06.mkv already exist. Do you want to overwrite it?
File /output/title_t07.mkv already exist. Do you want to overwrite it?
File /output/title_t08.mkv already exist. Do you want to overwrite it?
File /output/title_t09.mkv already exist. Do you want to overwrite it?
File /output/title_t10.mkv already exist. Do you want to overwrite it?
File /output/title_t11.mkv already exist. Do you want to overwrite it?
File /output/title_t12.mkv already exist. Do you want to overwrite it?
Program reads data faster than it can write to disk, consider upgrading your hard drive if you see many of these messages.
Program reads data faster than it can write to disk, consider upgrading your hard drive if you see many of these messages.
AV synchronization issues were found in file 'title_t02.mkv' (title #3)
Track #4 turned out to be empty and was removed from output file
AV synchronization issues were found in file 'title_t04.mkv' (title #5)
Track #4 turned out to be empty and was removed from output file
Program reads data faster than it can write to disk, consider upgrading your hard drive if you see many of these messages.
AV synchronization issues were found in file 'title_t05.mkv' (title #6)
Track #4 turned out to be empty and was removed from output file
13 titles saved
Copy complete. 13 titles saved.
A run connecting to the host network:
$ podman run -it --systemd=false --network=host -p 5800:5800 -v $HOME/makemkv/config:/config:rw -v /home/bward/emby/media:/storage:rw jlesage/makemkv:latest /bin/sh