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'
KonomiTV: Kind and Optimized Next brOadcast watching systeM Infrastructure for TV

備考・注意事項 現在 α 版で、まだ実験的なプロダクトです。通常利用には耐えないでしょうし、サポートもできません。 安定しているとは到底言いがたい品質ですが、それでも構わない方のみ導入してください。 使い方などの説明も用意できていないため、自力でトラブルに対処できるエンジニアの方以外には現状おすすめ

tsukumi 244 Dec 31, 2022
A simple Python Youtube Wachtime for YTbebot

Simple bot that was development in python 3.7, that automatically watch youtube videos. It can be used to give more views in your channel helping in the spread and increase the followers because your

Rian eka wiratma 1 Dec 05, 2021
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
BlogBot - a Python script that create blogs from YouTube videos.

BlogBot - Convert Youtube Videos To Blogs BlogBot is a Python script that create blogs from YouTube videos.

Nikhil Bhamere 4 Apr 22, 2022
LL-HLS implementation written in Python3

biim mpegts stream to Apple Low Latency HLS Feature mpegts demuxing in pure python3 (using asyncio) mpegts stream to fragmented ts use piping from ffm

もにょ~ん 15 Jan 03, 2023
Techie Sneh 17 Nov 23, 2021
Automatically logs into VTOP and can perform certain tasks

VTOP_Login Automatically logs into VTOP and can perform certain tasks To run the

Jatin 1 Jan 30, 2022
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
Examples of usage of GStreamer hlssink3 plugin.

Examples of usage of GStreamer hlssink3 plugin.

Rafael Carício 2 Aug 03, 2022
Telegram Video Stream

Video Stream An Advanced VC Video Player created for playing video in the voice chats of Telegram Groups And Channel Configs TOKEN - Get bot token fro

mr_lokaman 46 Dec 25, 2022
Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding

Av1an A cross-platform framework to streamline encoding Easy, Fast, Efficient and Feature Rich An easy way to start using AV1 / HEVC / H264 / VP9 / VP

Zen 947 Jan 01, 2023
获取斗鱼&虎牙&哔哩哔哩&抖音&快手等 48 个直播平台的真实流媒体地址(直播源)和弹幕,直播源可在 PotPlayer、flv.js 等播放器中播放。

获取斗鱼&虎牙&哔哩哔哩&抖音&快手等 48 个直播平台的真实流媒体地址(直播源)和弹幕,直播源可在 PotPlayer、flv.js 等播放器中播放。

乌帮图 5.6k Jan 06, 2023
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
This program is to make a video based on Deep Dream

This program is to make a video based on Deep Dream. The program is modified from DeepDreamAnim and DeepDreamVideo with additional functions for bleding two frames based on the optical flows. It also

Aertist 23 Jan 22, 2022
Search a video semantically with AI.

Which Frame? Search a video semantically with AI. For example, try a natural language search query like "a person with sunglasses". You can also searc

David Chuan-En Lin 1 Nov 06, 2021
A python generator that converts youtube videos to ascii art in your console.

Video To ASCII A python generator that converts youtube videos to ascii art in your console. This has not been tested for windows! Example Normal mode

Julian Jones 24 Nov 02, 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
This is a simple script to generate a .opml file from a list of youtube channels.

Youtube to rss Don't spend more time than you need to on youtube.com This is a simple script to generate a .opml file from a list of youtube channels.

Kostas 1 Oct 04, 2022
pygamevideo module helps developer to embed videos into their Pygame display

pygamevideo module helps developer to embed videos into their Pygame display. Audio playback doesn't use pygame.mixer.

Kadir Aksoy 10 Dec 28, 2022
Repository to create Ascii art in CMD based on video file.

Made to take any file format, and transform it into ascii art, displayed as a video in the cmd. If the cmd formatting is wrong, try zooming a little and remember to make cmd fullscreen. I made my cmd

60 Dec 17, 2022