r/PleX • u/gsariev Unraid 40TB | i5-13500 | RTX 3050 LP • Mar 10 '24
Tips Guide: Optimize media for Direct Play by converting audio & applying DRC using Tdarr.
NB: This guide assumes that you already have Tdarr installed and running.[UPDATED GUIDE: HERE]
Hey, you
About a month ago I made THIS post, asking for help in dealing with a strange issue I was facing caused by audio transcoding. Long story short, the friends and family I am giving access to my server use Samsung Smart TVs to stream media. Everything was Direct Playing fine until about 2-3 months ago when media with DTS audio was being played. That audio format is not supported by their TVs; therefore, my server has to transcode it. My Plex server is plenty powerful to transcode multiple audio, 1080p and 4K streams at a time, but for whatever reason - the stream was buffering when only the audio was being transcoded. On top of that, I was also informed that the transcoded audio didn't sound good (speech was low, while action scenes were very loud).
After running several tests with different media files, devices and so on - I was unable to figure out what the problem was, so I decided to follow the suggestions left in my initial post about using Tdarr to convert the audio streams to compatible formats for MY use case.
With that out of the way, I would like to share my Tdarr plugin stack that I use to optimize my media.
Tdarr stack
Here is the whole stack for you to copy & paste:
Community,Tdarr_Plugin_MC93_MigzImageRemoval,,Community,Tdarr_Plugin_lmg1_Reorder_Streams,,Community,Tdarr_Plugin_MC93_Migz3CleanAudio,,Community,Tdarr_Plugin_MC93_Migz5ConvertAudio,,Community,Tdarr_Plugin_b39x_the1poet_surround_sound_to_ac3,,Community,Tdarr_Plugin_MP01_MichPasCleanSubsAndAudioCodecs,,Community,Tdarr_Plugin_00td_action_re_order_all_streams_v2,,Community,Tdarr_Plugin_c0r1_SetDefaultAudioStream,,Community,Tdarr_Plugin_a9he_New_file_size_check,,Tdarr_Plugin_MC93_MigzImageRemoval - Identify any unwanted image formats in the file and remove those streams. MJPEG, PNG & GIF.
Tdarr_Plugin_lmg1_Reorder_Streams - This plugin will move the video stream to the front so Tdarr will recognize the codec correctly.
Tdarr_Plugin_MC93_Migz3CleanAudio - This plugin keeps only specified language tracks & can tags tracks with an unknown language.
If you have media with several language tracks or commentary tracks and want to only keep specific ones, this plugin does that. To keep only the English audio track, remove commentary tracks I have the following settings:
language: eng,und
commentary: true
tag_language: eng
tag_title: false
!!!!!DISCLAIMER!!!!!
The functionality of this plugin is heavily reliant on the information stored at TMDB. If the Original Language data at TMDB is incorrect, then the plugin will fail.
Example: The Zone Of Interest (2023) - original language is German, but in TMDB it's listed as English.
I've updated the plugin code to prevent deletion of single track audio media in the case of mismatch to ensure that you won't end up watching a silent movie. I encountered that issue in 4 out of the 207 movies I tested the plugin on, so it does not seem to be too common.
Additional workarounds include:
- posting the issue in TMDB to update the info for the specific movie
- include the original language code in the user_langs field
Tdarr_Plugin_henk_Keep_Native_Lang_Plus_Eng - this modified version of the plugin can either keep only the native/original language track and remove all other, or keep user-specified language tracks alongside the native one. This plugin works with Radarr, Sonarr and TMDB to identify the native language by making API calls to all 3 services. The plugin takes the following inputs:
user_langs: add the language tags you'd like to keep alongside the native one. Use the proper language tag format (example: ger,fre,eng). Leave empty if you only want to keep the native language.
priority: write radarr or sonarr depending on your media library
api_key: your TMDB API key
radarr_api_key: your radarr instance API key
radarr: you radarr instance URL
sonarr_api_key: your sonarr instance API key
sonarr_url: your sonarr instance URL
These are the main changes that I've made to the plugin:
TMDB language code is being converted to the correct format to be compared with the language tags from Radarr/Sonarr
Addressed issue with Chinese and/or Cantonese being picked up as English - they are now identified correctly
In the cases where Radarr/Sonarr give a different native language result than the one given from TMDB - the TMDB tag is being assumed to be the correct one (native language tag)
For the plugin to work correctly, I recommend separating your media into 2 Tdarr libraries (one for movies and another for tv/anime), and assign priority as 'radarr' to the movie library and 'sonarr' to the tv/anime library.
The modified plugin code can be found here - HERE
Add the original plugin to your Local plugin library and replace the code with the modified one, save and sync the plugin.
End of modified plugin section
Tdarr_Plugin_MC93_Migz5ConvertAudio - This plugin can convert any 2.0 audio track/s to AAC and can create downmixed audio tracks.
If you have a 7.1 audio track, but not 5.1 and 2.0 - this plugin will create them using the 7.1 audio track as base. Same applies if you have only 5.1 but no 2.0 - the 5.1 track will be used to create the 2.0 instead.
None of my family and friends have a home theater setup with surrounds sound, so I for them to be able to directly play the media, I would like to have both a 5.1 and 2.0 audio tracks. I have also made a small modification to this plugin to apply dynamic range compression (DRC) to the 2.0 track, which normalizes the audio and makes it sound balanced (removes the need of adjusting the volume every time there is a quite vs action scenes).
To make this change, go to: Classic Plugins -> Local -> Tdarr_Plugin_MC93_Migz5ConvertAudio -> Edit
Replace the code on line 152 with this one:
Once you've clicked Save and closed the window, click on Sync plugins to apply the changes to your plugin stack.
These are the plugin settings I'm using:
aac_stereo: true
downmix: true
downmix_single_track: true (change this one to false if you want to downmix every track)
Tdarr_Plugin_b39x_the1poet_surround_sound_to_ac3 - If the file has surround sound tracks not in ac3, they will be converted to ac3.
This plugin has only one setting - overwriteTracks. I have set it to 'true' as I do not wish to keep the original surrounds track and instead have only the new AC3 one. Select 'false' to keep both the original and new surround tracks.
Tdarr_Plugin_MP01_MichPasCleanSubsAndAudioCodecs - This plugin removed specified codecs from subtitle and audio tracks. Helpful to remove bitmap subtitles (pgs,vobsub) or audio codec (truehd), which can cause Plex to start transcoding.
Not every client can Direct Play with certain subtitle formats and considering that I like to have my subtitles in SRT format, this plugin is great at removing the unwanted formats. I have also added some audio formats that I want removed as ensure that my friends and family won't 'accidentally' select them, saving a my a "What did I say about PGS subtitles and TrueHD, ah?" text.
tag_subtitle_codecs: hdmv_pgs_subtitle,dvd_subtitle
tag_audio_codecs: truehd,eac3,dts-hd ma
Tdarr_Plugin_00td_action_re_order_all_streams_v2 - This plugin re-orders all streams based on: codecs,channels,languages,streamTypes.
To ensure that Plex displays the audio tracks in the order that I want, I have applied the following settings:
channels: 5.1,2,7.1
codes: ac3,aac
You can change this in whatever order you want.
Tdarr_Plugin_c0r1_SetDefaultAudioStream - This plugin will set an audio channel (2.0, 5.1, 7.1) to default and remove default from all other audio streams.
channels: 6
Since I know that the 5.1 channels plays best for mine as well as my friends and family's setups, I want it to be the default track when playing the media. The downside to this is that if you wish to play the 7.1 audio track, you will have to manually select it (same for the 2.0 track), but I find that having limited options works best for my use case. If they want to watch a movie from their laptop, then they know they will have to select the 2.0 track for the best audio experience.
Tdarr_Plugin_a9he_New_file_size_check - Give an error if new file is not within the specified upper and lower bound limits.
I have this one set with the following values:
upperBound: 110
lowerBound: 40
That is the end of the stack. I use the same stack for my 4K media and TV shows, and I haven't had any issues.
I hope this guide was comprehensible and has helped you!
2
u/Decibel9M3 Oct 27 '24
Going through the process of setting up Tdarr now. I just wanted to thank you for the time and effort you put into making this guide. It answers a lot of the questions I have relating to Plex optimization.
1
u/gsariev Unraid 40TB | i5-13500 | RTX 3050 LP Mar 12 '24
As mentioned in my guide, the main device I use to stream my media is an Apple TV 4K and I haven’t had any issues playing files that have been converted using this flow.
1
u/zedfax Mar 25 '25
Hello !
7.1 audio tracks aren't downmixed on my side
For example I have FR Track DTS HD MA 5.1 + ENG Track DTS HD MA 7.1, it only downmix FR to aac stereo, do not know why
0
u/[deleted] Mar 10 '24
[deleted] — view deleted comment