Help for manipulating the plex-media-server transcode on the raspberry pi

Overview

raspi-plex-transcode

Help for manipulating the plex-media-server transcode on the raspberry pi

Ensure hardware decoding works and your firmware is up to date

As mentioned in this forum post: https://forums.raspberrypi.com/viewtopic.php?t=262558

Hardware decoding of h264 will NOT WORK if the gpu memory is limited. I had added gpu=16 in my config.txt since I run my pi headless and thought it to be a waste of ram. Setting it to gpu=128 (the default) should be fine.

Brought to my attention by "fancybits" in the plex forums it is recommended to update the rpi kernel and firmware by running sudo rpi-update.

https://forums.plex.tv/t/hardware-transcoding-for-raspberry-pi-4-plex-media-server/538779/236

Compiling plex ffmpeg with custom options

Here is what I did to compile the plex-fork of ffmpeg:

cd /home/pi
cat /usr/lib/plexmediaserver/Resources/LICENSE | grep "Plex Transcoder"
# Copy the URL from the grep command and use it for the following wget
wget https://downloads.plex.tv/ffmpeg-source/plex-media-server-ffmpeg-gpl-62cc2bc17d.tar.gz
tar -xvf plex-media-server-ffmpeg-gpl-*.tar.gz
rm plex-media-server-ffmpeg-gpl-*.tar.gz
mv plex-media-server-ffmpeg-gpl-* plex-media-server-ffmpeg
cd plex-media-server-ffmpeg
sudo apt install libass-dev libaom-dev libxvidcore-dev libvorbis-dev libv4l-dev libx265-dev libx264-dev libwebp-dev libspeex-dev librtmp-dev libopus-dev libmp3lame-dev libdav1d-dev libopencore-amrnb-dev libopencore-amrwb-dev libsnappy-dev libsoxr-dev libssh-dev libxml2-dev libomxil-bellagio-dev
# If you want to apply patches or make changes to the ffmpeg source, do it here
./configure --extra-cflags="-I/usr/local/include" --extra-ldflags="-L/usr/local/lib" --extra-libs="-lpthread -lm -latomic" --enable-gmp --enable-gpl --enable-libaom --enable-libass --enable-libdav1d --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libssh --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-mmal --enable-omx --enable-nonfree --enable-version3 --target-os=linux --enable-pthreads --enable-openssl --enable-hardcoded-tables
make -j5
sudo usermod -a -G video plex

Hooking into the plex transcode process

In order to use a different (hardware-)encoder I wrote a small shell script that can be put in place like this:

cd /home/pi/plex-media-server-ffmpeg
wget https://github.com/ForsakenNGS/raspi-plex-transcode/raw/main/ffmpeg-transcode
wget https://github.com/ForsakenNGS/raspi-plex-transcode/raw/main/ffmpeg-transcode.yaml
# Edit the configuration file to your needs
chmod +x ffmpeg-transcode
cd /usr/lib/plexmediaserver/
sudo mv 'Plex Transcoder' 'Plex Transcoder Backup'
sudo ln -s /home/pi/plex-media-server-ffmpeg/ffmpeg-transcode 'Plex Transcoder'

This will replace the output video encoder with the one defined in the configuration. (by default h264_v4l2m2m) Also it increases the buffer size (double of default) and allows to change the segment duration of the chunks that are being rendered.

Configuration

The wrapper ffmpeg-transcode will replace the plex parameters according to the configuration file ffmpeg-transcode.yaml. An example can be found in this repository as instructed to download above. The following options are available:

executable (required)

Defines the ffmpeg executable that is invoked with the altered parameters. The default is /home/pi/plex-media-server-ffmpeg/ffmpeg

profiles (required)

A list of profiles indexed by name that are being used to adjust the plex parameters. Each profile requires an input and output key which defines overrides for the default parameters. An example as included in the default configuration:

'profiles':
  'default':
    'input':
    'output':
      '-codec:0': 'h264_v4l2m2m'
      '-crf:0': '10'
      '-minrate:0': '1M'
      '-maxrate:0': '5M'
      '-bufsize:0': '10M'
      '-seg_duration': '2'
  • Everything in the input section applies to the input stream (everything before the -i filename parameter).
  • Everything in the output section applies to the output stream (everything after the -i filename parameter).
  • Any valid ffmpeg parameter can be used.
  • Repetitions of the same parameter are currently not supported.

profile_select

Controls when certain profiles are used. The following child-keys are available:

  • default Defines a default profile which is used if no other rule matches. Example:
'profile_select':
  'default': 'default'
  • by_argument Defines conditions which will trigger a certain profile to be used.
    • argSection One of either input or output. This will decide whether the script will check the given argument for the input or the output stream.
    • argName The name of the argument as supplied by plex. e.g.: -codec:0 will check the video codec, -i will check the input file.
    • type What kind of condition will be checked. Available are:
      • exact Matches if the given value parameter matches the value of the specified argument.
      • regex Matches if the regex supplied within the value parameter matches the value of the specified argument.
      • present Matches if the specified argument is present.
      • missing Matches if the specified argument is missing.
    • ignorecase Currently only used for the regex type. Makes the regular expression case insensitive.
    • value The value used for matching with the exact and regex types.
    • profile The target profile as defined in the profiles section that is used if the condition matches.
    • priority A priority that is used when multiple conditions match. Higher is more important. If omitted the default priority of 0 is used.

Example that will match if the path or filename contain the string anime somewhere:

'profile_select':
  'by_argument':
    -
      'argSection': 'input'
      'argName': '-i'
      'type': 'regex'
      'ignorecase': true
      'value': '.*anime.*'
      'profile': 'anime'
Extracting frames from video and create video using frames

Extracting frames from video and create video using frames This program uses opencv library to extract the frames from video and create video from ext

1 Nov 19, 2021
Spotify playlist video generator

This program creates a video version of your Spotify playlist by using the Spotify API and YouTube-dl.

0 Mar 03, 2022
Filtering user-generated video content(SberZvukTechDays)Filtering user-generated video content(SberZvukTechDays)

Filtering user-generated video content(SberZvukTechDays) Table of contents General info Team members Technologies Setup Result General info This is a

Roman 6 Apr 06, 2022
GStreamer Inspector GUI

gst-explorer GStreamer GUI Interface Tool GUI interface for inspecting GStreamer Plugins, Elements and Type Finders. Expects Python3 Qt, PyQt5 and GSt

Jetsonhacks 31 Nov 29, 2022
Create a Video Membership app using FastAPI & NoSQL

Video Membership Create a Video Membership app using FastAPI & NoSQL. In this series, we're going to explore building a membership application using F

Coding For Entrepreneurs 69 Dec 25, 2022
It is a simple python package to play videos in the terminal using characters as pixels

It is a simple python package to play videos in the terminal using characters as pixels

Joel Ibaceta 1.4k Jan 07, 2023
Vigia-youtube - The YouTube Watch bot is able to monitor channels on Google's video platform

Vigia do YouTube O bot Vigia do YouTube é capaz de monitorar canais na plataform

Alessandro Feitosa Jr 10 Oct 03, 2022
基于BililiveRecorder 的集群录播客户端

高度自动化的录播服务端! 一、项目介绍 1、介绍 这是NGlive的录播服务器集群的客户端部分实现代码,它可以自动化的进行录制-压制-上传-通知,同时流程高度可自定义,并且可以任意受中心服务器的调度,有一定的错误修复能力。可以保证长期稳定的运行。 2、基本功能 这个客户端集 录制、转码压制、上传为一

NGWORKS 7 Jul 10, 2022
Tweet stream in OBS browser source

OBS-Twitter-Stream OBSなどの配信ソフトのブラウザソースで特定のキーワードを含んだツイートを表示します 使い方 使い方については以下のwikiを御覧ください https://github.com/CubeZeero/OBS-Twitter-Stream/wiki ダウンロード W

Cube 23 Dec 18, 2022
Скрипт который выводит видео в консоль. Ничего лишнего)

video-to-ascii Скрипт который выводит видео в консоль. Ничего лишнего) Требования Минимальное разрешение экрана: 1280x720 Видео в качестве 360p 10-45f

Daniil Pisarev 155 Nov 28, 2022
This application makes a webrtc video call with jitsi meet signaling

gstreamer-jitsi-meet This application makes a webrtc video call with jitsi meet signaling. Other end can be any jitsi meet app or web app. It doesn't

Linh 7 Apr 26, 2022
Video-stream - A telegram video stream bot repo

This is a Telegram Video stream Bot. Binary Tech 💫 Features stream videos downl

silentz lk 1 Feb 02, 2022
pyffstream - A CLI frontend for streaming over SRT and RTMP specializing in sending off files

pyffstream - A CLI frontend for streaming over SRT and RTMP specializing in sending off files

Gregory Beauregard 3 Mar 04, 2022
Program for converting video to GIF

video-to-gif Program for converting video to GIF Install the lib: pip install moviepy Usage: Specify the path to the video file. clip = VideoFileClip(

Artem Mokin 0 Dec 13, 2021
Code from the 2021 Signal Video Superclass

Twilio Video Demo This is the code written during the live Twilio Video demo during Twilio's Signal 2021 Superclass. It creates a simple Video applica

2 Oct 21, 2021
Home Assistant custom component for viewing IP cameras RTSP stream in real time using WebRTC technology

WebRTC Camera Home Assistant custom component for viewing IP cameras RTSP stream in real time using WebRTC technology. Based on: Pion - pure Go implem

Alex X 739 Dec 30, 2022
Video Object Segmentation(VOS) From Zero to HeroVideo Object Segmentation(VOS) From Zero to Hero

Video Object Segmentation(VOS) From Zero to Hero! Goal 1:train a two layers cnn model for vos. Finish! see model.py FFNet for more diteal.(2021.9.30)

1 Oct 22, 2021
video streaming userbot (vsu) based on pytgcalls for streaming video trought the telegram video chat group.

VIDEO STREAM USERBOT ✨ an another telegram userbot for streaming video trought the telegram video chat. Environmental Variables 📌 API_ID : Get this v

levina 6 Oct 17, 2021
Convert lecture videos to slides in one line. Takes an input of a directory containing your lecture videos and outputs a directory containing .PDF files containing the slides of each lecture.

Convert lecture videos to slides in one line. Takes an input of a directory containing your lecture videos and outputs a directory containing .PDF files containing the slides of each lecture.

Sidharth Anand 12 Sep 10, 2022
Your self hosted Youtube media server

The Tube Archivist Your self hosted Youtube media server Core functionality Subscribe to your favourite Youtube channels Download Videos using yt-dlp

Simon 2.1k Dec 31, 2022