mirror of
https://github.com/joshuaboniface/rffmpeg.git
synced 2026-01-23 02:24:03 +00:00
Update README with new setup information
This commit is contained in:
parent
022334e1e9
commit
48b9741af5
1 changed files with 44 additions and 45 deletions
89
README.md
89
README.md
|
|
@ -18,55 +18,54 @@ rffmpeg is a remote FFmpeg wrapper used to execute FFmpeg commands on a remote s
|
|||
|
||||
1. Profit!
|
||||
|
||||
## Full setup
|
||||
|
||||
This example setup is the one I use for `rffmpeg`, involving a Jellyfin server (`jf1`) and a remote transcode server (`gpu1`).
|
||||
|
||||
1. Prepare the remote transcode server. This involves the following steps:
|
||||
|
||||
1. Install any required tools or programs to make use of hardware transcoding. This is optional if you only plan to use software (i.e. CPU) transcoding.
|
||||
|
||||
1. Create a temporary transcoding directory somewhere on the system. Ideally, this should be fast scratch storage with no persistence required. In my case I use a pair of RAID-0 SSDs, though you could use a ramdisk if you have sufficient RAM. For my purposes, I put this directory at `/var/transcode` and mount my SSD RAID there.
|
||||
|
||||
1. Create a user to accept SSH connections in and run the FFmpeg commands. I use a user called `jellyfin` with a home directory of `/var/lib/jellyfin`, identical to the user that is created by the Jellyfin server itself - this is important for the directory layout to work. For maximum compatibility, ensure this user has the exact same Unix UID as the Jellyfin user on your Jellyfin host.
|
||||
|
||||
1. Ensure the temporary transcoding directory is owned by the new user.
|
||||
|
||||
1. Create a symlink from the user's home directory to the temporary transcoding directory. This much match the Jellyfin file layout to preserve paths. For insance, if your `transcoding-temp` directory on the Jellyfin server is at `/var/lib/jellyfin/transcoding-temp`, the symlink must exist at the same location on the transcode server.
|
||||
|
||||
1. Similarly to the transcoding directory, ensure your media volume is mounted on the transcode server at the same location as on the Jellyfin server.
|
||||
|
||||
1. Install an FFmpeg binary, in my case the `jellyfin-ffmpeg` package, on the transcode server.
|
||||
|
||||
1. Install the NFS kernel server, and set up an export of your temporary transcoding directory such that the Jellyfin server can mount it.
|
||||
|
||||
1. On your Jellyfin server, create a new SSH private keypair owned by the Jellyfin service user.
|
||||
|
||||
1. Install the public key of the new SSH private keypair under the remote user on the transcode server.
|
||||
|
||||
1. Verify that SSH is successful from the Jellyfin server (as the Jellyfin user) to the transcode server as expected. Running `sudo -u <jellyfin-user> rffmpeg.py` once with no arguments will accomplish this test. This also ensures that the SSH host key of the remote server is saved before Jellyfin attempts to run the command.
|
||||
|
||||
1. Install the NFS client, and mount the temporary transcoding directory from the remote server to your `transcoding-temp` directory as set in Jellyfin. Ensure the mount is synchronous, and is over a high-MTU link for maximum performance.
|
||||
|
||||
1. Install the `rffmpeg` program as detailed above.
|
||||
|
||||
1. In Jellyfin, set the `rffmpeg.py` binary, via its `ffmpeg` symlink, as your "FFmpeg path". The symlinks are important for Jellyfin to properly call the `ffprobe` command as well.
|
||||
|
||||
1. Try running a transcode and verifying that the `rffmpeg` program works as expected. The flow should be:
|
||||
|
||||
1. Jelyfin calls `rffmpeg.py` with the expected arguments.
|
||||
|
||||
1. FFmpeg begins running on the transcode server; the file paths should all be valid there as they would be on the Jellyfin machine.
|
||||
|
||||
1. The FFmpeg process writes the output files to the NFS-exported temporary transcoding directory.
|
||||
|
||||
1. Jelyfin reads the output files from the NFS-mounted temporary transcoding directory and plays back normally.
|
||||
|
||||
## rffmpeg options
|
||||
|
||||
### Remote hosts
|
||||
|
||||
rffmpeg supports setting multiple hosts. It keeps state in `/run/shm/rffmpeg`, of all running processes. These state files are used during rffmpeg's initialization in order to determine the optimal target host. rffmpeg will run through these hosts sequentially, choosing the one with the fewest running rffmpeg jobs. This helps distribute the transcoding load across multiple servers.
|
||||
|
||||
Note however that this setup is NOT compatible with the simple NFS-based export mentioned above. For this to work properly, ALL the involved hosts must share the same temporary storage, for instance exported from another machine to the source and transcode hosts.
|
||||
## Full setup guide
|
||||
|
||||
This example setup is the one I use for `rffmpeg`, involving a media server (`jf1`) and a remote transcode server (`gpu1`). Both systems run Debian GNU/Linux, though the commands below should also work on Ubuntu.
|
||||
|
||||
1. Prepare the media server (`jf1`) with Jellyfin. Make note of the "Transcode path" in the Playback settings menu (e.g. `/var/lib/jellyfin/transcoding-temp`).
|
||||
|
||||
1. On the media server, create an SSH keypair owned by the Jellyfin service user; save this SSH key somewhere readable to the service user: `sudo -u jellyfin mkdir -p /var/lib/jellyfin/.ssh && sudo -u jellyfin ssh-keygen -t rsa -f /var/lib/jellyfin/.ssh/id_rsa`
|
||||
|
||||
1. Install the rffmpeg program as detailed in the above section, including creating the `/etc/rffmpeg/rffmpeg.yml` configuration file and symlinks.
|
||||
|
||||
1. Install the NFS kernel server: `sudo apt -y install nfs-kernel-server`
|
||||
|
||||
1. Export the "Transcode path" directory found in step 1 with NFS; you will need to know the local IP address of the transcode server(s) (e.g. `10.0.0.100`) to lock this down; alternatively, use your entire local network range (e.g. `10.0.0.0/24`): `echo '/var/lib/jellyfin/transcoding-temp 10.0.0.100/32(rw,sync,no_subtree_check)' | sudo tee -a /etc/exports && sudo systemctl restart nfs-kernel-server`
|
||||
|
||||
1. On the transcode server, install any required tools or programs to make use of hardware transcoding; this is optional if you only use software (i.e. CPU) transcoding.
|
||||
|
||||
1. Install the `jellyfin-ffmpeg` package to provide an FFmpeg binary; follow the Jellyfin installation instructions for details on setting up the Jellyfin repository, though install only `jellyfin-ffmpeg`.
|
||||
|
||||
1. Install the NFS client utilities: `sudo apt install -y nfs-common`
|
||||
|
||||
1. Create a user for rffmpeg to SSH into the server as. This user should match the `jellyfin` user on the media server in every way, including UID (`id jellyfin` on the media server), home path, and groups.
|
||||
|
||||
1. Install the SSH public key created in step 2 into the new user's home directory: `sudo -u jellyfin mkdir -p /var/lib/jellyfin/.ssh && echo 'ssh-rsa MyJellyfinUserPublicKey' | sudo -u jellyfin tee /var/lib/jellyfin/.ssh/authorized_keys`
|
||||
|
||||
1. Ensure that the "Transcode path" directory exists at the same location as on the media server; create it if required: `sudo mkdir -p /var/lib/jellyfin/transcoding-temp`
|
||||
|
||||
1. Mount the media server NFS transcode share at the transcode directory: `echo 'jf1:/var/lib/jellyfin/transcoding-temp /var/lib/jellyfin/transcoding-temp nfs defaults,vers=3,sync 0 0' | sudo tee -a /etc/fstab && sudo mount -a`
|
||||
|
||||
1. Mount your media directory on the transcode server at the same location as on the media server and using the same method; if your media is local to the media server, export it with NFS similarly to the transcode directory.
|
||||
|
||||
1. On the media server, attempt to SSH to the transcode server as the `jellyfin` user using the key from step 2; this both tests the connection as well as saves the transcode server SSH host key locally: `sudo -u jellyfin ssh -i /var/lib/jellyfin/.ssh/id_rsa jellyfin@gpu1`
|
||||
|
||||
1. Verify that rffmpeg itself works by calling its `ffmpeg` alias with the `-version` option: `sudo -u jellyfin /usr/local/bin/ffmpeg -version`
|
||||
|
||||
1. In Jellyfin, set the rffmpeg binary, via its `ffmpeg` symlink, as your "FFmpeg path" in the Playback settings; optionally, enable any hardware encoding you configured in step 6.
|
||||
|
||||
1. Try running a transcode and verifying that the `rffmpeg` program works as expected. The flow should be:
|
||||
|
||||
1. Jellyfin calls rffmpeg with the expected arguments.
|
||||
|
||||
1. FFmpeg begins running on the transcode server.
|
||||
|
||||
1. The FFmpeg process writes the output files to the NFS-mounted temporary transcoding directory.
|
||||
|
||||
1. Jellyfin reads the output files from the NFS-exported temporary transcoding directory and plays back normally.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue