Skip to content

Commit 081a797

Browse files
authored
Merge pull request #451 from junkman690/jellyfin-rffmpeg
jellyfin:rffmpeg initial release
2 parents 413aa51 + 13bd1da commit 081a797

File tree

27 files changed

+331
-73
lines changed

27 files changed

+331
-73
lines changed

.github/workflows/BuildImage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on: [push, pull_request, workflow_dispatch]
44

55
env:
66
ENDPOINT: "linuxserver/mods" #don't modify
7-
BASEIMAGE: "replace_baseimage" #replace
8-
MODNAME: "replace_modname" #replace
7+
BASEIMAGE: "jellyfin" #replace
8+
MODNAME: "rffmpeg" #replace
99

1010
jobs:
1111
build:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM scratch
22

3-
LABEL maintainer="username"
3+
LABEL maintainer="junkman690"
44

55
# copy local files
66
COPY root/ /

Dockerfile.complex

Lines changed: 0 additions & 23 deletions
This file was deleted.

README.md

Lines changed: 80 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,88 @@
1-
# Rsync - Docker mod for openssh-server
1+
# rffmpeg - Docker mod for Jellyfin
22

3-
This mod adds rsync to openssh-server, to be installed/updated during container start.
3+
This mod adds rffmpeg to Linuxserver.io's Jellyfin https://github.com/linuxserver/docker-jellyfin.
44

5-
In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync`
5+
rffmpeg is a remote FFmpeg wrapper used to execute FFmpeg commands on a remote server via SSH. It is most useful in situations involving media servers such as Jellyfin (our reference user), where one might want to perform transcoding actions with FFmpeg on a remote machine or set of machines which can better handle transcoding, take advantage of hardware acceleration, or distribute transcodes across multiple servers for load balancing.
66

7-
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-rsync|linuxserver/mods:openssh-server-mod2`
7+
See https://github.com/joshuaboniface/rffmpeg for more details about rffmpeg
88

9-
# Mod creation instructions
9+
In Jellyfin docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:jellyfin-rffmpeg`
1010

11-
* Fork the repo, create a new branch based on the branch `template`.
12-
* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done.
13-
* Inspect the `root` folder contents. Edit, add and remove as necessary.
14-
* Edit this readme with pertinent info, delete these instructions.
15-
* Finally edit the `.github/workflows/BuildImage.yml`. Customize the build branch, and the vars for `BASEIMAGE` and `MODNAME`.
16-
* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch.
17-
* Submit PR against the branch created by the team.
11+
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:jellyfin-rffmpeg|linuxserver/mods:jellyfin-mod2`
1812

13+
This mod requires you to update the rffmpeg.yml located in "Your jellyfin config dir"/rffmpeg/rffmpeg.yml with your remote SSH username. You also need to add your authorized SSH file to "Your jellyfin config dir"/rffmpeg/.ssh/id_rsa"
1914

20-
## Tips and tricks
15+
You can specify the remote SSH username and host using ENV, note currently only supports 1 host and doesn't overwrite values other than defaults:
16+
* RFFMPEG_USER= remote SSH username
17+
* RFFMPEG_HOST= remote server name or IP
2118

22-
* To decrease startup times when multiple mods are used, we have consolidated `apt-get update` down to one file. As seen in the [nodejs mod](https://github.com/linuxserver/docker-mods/tree/code-server-nodejs/root/etc/cont-init.d)
23-
* Some images has helpers built in, these images are currently:
24-
* [Openvscode-server](https://github.com/linuxserver/docker-openvscode-server/pull/10/files)
25-
* [Code-server](https://github.com/linuxserver/docker-code-server/pull/95)
19+
You also need to ensure that /cache inside the container is exported on the host so it can be mapped on the remote host. Eg for docker compose.
20+
```yaml
21+
volumes:
22+
- "Your jellyfin config dir":/config
23+
- "Your jellyfin config dir"/cache:/cache
24+
```
25+
See https://github.com/joshuaboniface/rffmpeg/blob/master/SETUP.md NFS setup for more details
26+
27+
EXAMPLE Docker-Compose file with WOL support via API:
28+
29+
```yaml
30+
---
31+
version: "2.1"
32+
services:
33+
jellyfin:
34+
image: lscr.io/linuxserver/jellyfin:latest
35+
container_name: jellyfin
36+
environment:
37+
- PUID=1000
38+
- PGID=1000
39+
- TZ=Europe/London
40+
- RFFMPEG_USER=jellyfin
41+
- RFFMPEG_WOL=api
42+
- RFFMPEG_HOST=transcode
43+
- RFFMPEG_HOST_MAC="12:ab:34:cd:ef:56"
44+
- WOL_API=192.168.1.5 #docker host IP
45+
- WOL_API_PORT=8431
46+
- WOL_WAIT=10 #time transcode host takes to start
47+
volumes:
48+
- /path/to/jellyfin/config:/config
49+
- /path/to/jellyfin/config/cache:/cache
50+
- /path/to/data:/data/
51+
ports:
52+
- 8096:8096
53+
- 8920:8920 #optional
54+
- 7359:7359/udp #optional
55+
- 1900:1900/udp #optional
56+
restart: unless-stopped
57+
depends_on:
58+
- wol_api
59+
wol_api:
60+
image: rix1337/docker-wol_api
61+
container_name: wol_api
62+
environment:
63+
- PORT=8431
64+
network_mode: host
65+
restart: unless-stopped
66+
```
67+
68+
If you want to run rffmpeg commands they must be run as ABC inside the container eg:
69+
* To add new host ``` docker exec -it jellyfin s6-setuidgid abc /usr/local/bin/rffmpeg add --weight 1 remotehost ```
70+
* To view status ``` docker exec -it jellyfin s6-setuidgid abc /usr/local/bin/rffmpeg status ```
71+
* To test connection ``` docker exec -it jellyfin s6-setuidgid abc /usr/local/bin/ffmpeg -version ```
72+
* To test connection ``` docker exec -it jellyfin s6-setuidgid abc /usr/local/bin/ffprobe -version ```
73+
* To view all commands ``` docker exec -it jellyfin s6-setuidgid abc /usr/local/bin/rffmpeg -h ```
74+
75+
You then need to set your FFMPEG binary in Jellyfin to:
76+
* /usr/local/bin/ffmpeg - Normal rffmpeg without WOL support
77+
* /usr/local/bin/wol_rffmpeg/ffmpeg - rffmpeg with WOL support
78+
79+
WOL Support
80+
Native WOL support is available if you are running in host network mode. If not you can use the WOL_API container https://hub.docker.com/r/rix1337/docker-wol_api. Note the image name is rix1337/docker-wol_api
81+
82+
WOL ENV:
83+
* RFFMPEG_WOL= native or api
84+
* RFFMPEG_HOST= remote host to wake
85+
* RFFMPEG_HOST_MAC= remote host to wake mac enclosed in " " eg "aa:12:34:bb:cc:56"
86+
* WOL_API = IP of docker host
87+
* WOL_API_PORT= port wol_api is running on
88+
* WOL_WAIT= time in seconds to wait for host to wake

root/defaults/rffmpeg.yml.sample

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
# Configuration file for rffmpeg
3+
#
4+
# Copy this sample to /etc/rffmpeg/rffmpeg.yml and replace the various attributes
5+
# with the values for your environment. For more details please see the README.
6+
#
7+
# Any commented value represents the default. Uncomment and alter as required.
8+
9+
rffmpeg:
10+
# Logging configuration
11+
logging:
12+
# Enable or disable file logging.
13+
#log_to_file: true
14+
15+
# Log messages to this file.
16+
# Ensure the user running rffmpeg can write to this directory.
17+
#logfile: "/var/log/jellyfin/rffmpeg.log"
18+
19+
# Show debugging messages
20+
#debug: false
21+
22+
# Directory configuration
23+
directories:
24+
# Persistent directory to store state database.
25+
#state: "/var/lib/rffmpeg"
26+
27+
# Temporary directory to store SSH persistence sockets.
28+
#persist: "/run/shm"
29+
30+
# The user who should own the state directory and database.
31+
# This should normally be the user who normally runs rffmpeg commands (i.e. the media
32+
# server service user).
33+
#owner: jellyfin
34+
35+
# The group who should own the state directory and database (an administrative group).
36+
# Use this group to control who is able to run "rffmpeg" management commands; users in
37+
# this group will have unlimited access to the tool to add/remove hosts, view status, etc.
38+
#group: sudo
39+
40+
# Remote (SSH) configuration
41+
remote:
42+
# The remote SSH user to connect as.
43+
#user: jellyfin
44+
45+
# How long to persist SSH sessions; 0 to disable SSH persistence.
46+
#persist: 300
47+
48+
# A YAML list of additional SSH arguments (e.g. private keys).
49+
# One entry line per space-separated argument element.
50+
#args:
51+
# - "-i"
52+
# - "/var/lib/jellyfin/id_rsa"
53+
54+
# Remote command configuration
55+
commands:
56+
# The path (either full or in $PATH) to the default SSH binary.
57+
#ssh: "/usr/bin/ssh"
58+
59+
# A YAML list of prefixes to the ffmpeg command (e.g. sudo, nice, etc.).
60+
# One entry line per space-separated command element.
61+
#pre:
62+
# - ""
63+
64+
# The (remote) ffmpeg and ffprobe command binary paths.
65+
#ffmpeg: "/usr/lib/jellyfin-ffmpeg/ffmpeg"
66+
#ffprobe: "/usr/lib/jellyfin-ffmpeg/ffprobe"
67+
68+
# Optional local fallback ffmpeg and ffprobe binary paths, if different from the above.
69+
#fallback_ffmpeg: "/usr/lib/jellyfin-ffmpeg/ffmpeg"
70+
#fallback_ffprobe: "/usr/lib/jellyfin-ffmpeg/ffprobe"

root/etc/cont-init.d/95-apt-get

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
apt-get update

root/etc/cont-init.d/98-rffmpeg

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
#Install dependancies
4+
apt-get install -y --no-install-recommends \
5+
iputils-ping \
6+
openssh-client \
7+
python3-click \
8+
python3-yaml \
9+
wakeonlan
10+
11+
#Grab Config
12+
mkdir -p \
13+
/etc/rffmpeg \
14+
/config/rffmpeg/.ssh
15+
touch /config/rffmpeg/.ssh/id_rsa
16+
chmod 600 /config/rffmpeg/.ssh/id_rsa
17+
if [ -f /config/rffmpeg/rffmpeg.yml ]; then
18+
echo "**** rffmpeg.yml already present ****"
19+
else
20+
echo "**** Creating rffmpeg.yml from sample ****"
21+
cp /defaults/rffmpeg.yml.sample /config/rffmpeg/rffmpeg.yml
22+
fi
23+
24+
#Grab rffmpeg
25+
mkdir -p /usr/local/bin/
26+
echo "**** Grabbing rffmpeg from upstream ****"
27+
rm -rf /usr/local/bin/rffmpeg
28+
curl -L -o /usr/local/bin/rffmpeg https://raw.githubusercontent.com/joshuaboniface/rffmpeg/master/rffmpeg
29+
chmod +x /usr/local/bin/rffmpeg
30+
31+
##Update rffmpeg.yml
32+
sed -i 's~#persist: "/run/shm"~persist: "/dev/shm"~' /config/rffmpeg/rffmpeg.yml
33+
sed -i 's~#state: "/var/lib/rffmpeg"~state: "/config/rffmpeg"~' /config/rffmpeg/rffmpeg.yml
34+
sed -i 's~#logfile: "/var/log/jellyfin/rffmpeg.log"~logfile: "/config/rffmpeg/rffmpeg.log"~' /config/rffmpeg/rffmpeg.yml
35+
sed -i 's~#log_to_file: true~log_to_file: true~' /config/rffmpeg/rffmpeg.yml
36+
sed -i 's~#owner: jellyfin~owner: abc~' /config/rffmpeg/rffmpeg.yml
37+
sed -i 's~#group: sudo~group: abc~' /config/rffmpeg/rffmpeg.yml
38+
sed -i 's~#args:~args:~' /config/rffmpeg/rffmpeg.yml
39+
sed -i 's~# - "-i"~ - "-i"~' /config/rffmpeg/rffmpeg.yml
40+
sed -i 's~# - "/var/lib/jellyfin/id_rsa"~ - "/config/rffmpeg/.ssh/id_rsa"~' /config/rffmpeg/rffmpeg.yml
41+
if [ ! -z "$RFFMPEG_USER" ]; then
42+
sed -i "s~#user: jellyfin~user: $RFFMPEG_USER~" /config/rffmpeg/rffmpeg.yml
43+
fi
44+
45+
#Fix permissions
46+
chown abc:abc -R /config/rffmpeg
47+
48+
#Initialize database
49+
if [ -f /config/rffmpeg/rffmpeg.db ]; then
50+
echo "**** DB already inialized ****"
51+
else
52+
echo "**** Initialize database ****"
53+
/usr/local/bin/rffmpeg init --yes
54+
#Add host
55+
if [ ! -z "$RFFMPEG_HOST" ]; then
56+
s6-setuidgid abc /usr/local/bin/rffmpeg add --weight 1 $RFFMPEG_HOST
57+
fi
58+
fi

root/etc/cont-init.d/98-vpn-config

Lines changed: 0 additions & 27 deletions
This file was deleted.

root/etc/rffmpeg/rffmpeg.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/config/rffmpeg/rffmpeg.yml

root/etc/s6-overlay/s6-rc.d/init-mod-jellyfin-rffmpeg-add-package/dependencies.d/init-mods

Whitespace-only changes.

0 commit comments

Comments
 (0)