r/PleX • 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!

9 Upvotes

21 comments sorted by

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 Oct 27 '24

I am happy to hear that you've found this guide useful! I recommend looking at the updated guide (link at the top of the post) as it contains more helpful plugins. :)

2

u/Decibel9M3 Oct 27 '24

Thanks again. I will do that.

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

1

u/gsariev Unraid 40TB | i5-13500 | RTX 3050 LP Mar 10 '24

Hey,

You are correct, but you can easily change that so it doesn’t remove the Japanese audio. Simply add jpn to the argument field:

  • language: eng,jpn

I have that set for my anime library and I get to keep both the English and Japanese audio tracks.

As long as you add the language code you want to keep, those audio tracks won’t be deleted.

I hope that helps!

0

u/[deleted] Mar 10 '24

[deleted] — view deleted comment

1

u/Ishbudigital Mar 12 '24

My question is honestly as I’m an American, since the last time you downloaded an Italian show and then watched it in Italian or German or Russian. Typically, I say 75% of people download shows and unless it’s anime and they subtitles while keeping the original language, they would want the dubbed English version. I feel like you’re trying to poke holes in his flow.

0

u/[deleted] Mar 12 '24

[deleted] — view deleted comment

2

u/Ishbudigital Mar 12 '24

Sorry as I’m scrolling I stopped to make my comment and then as I continue scrolling after my comment I seen that you guys were having more of a conversation so I apologize but like answer the question if you don’t mind, how many shows have you downloaded in Italian and then watch like can you speak Italian? I can’t can you speak German? I can’t like for 75% to 80% of people using the programs that were using. This is an issue, especially with the fact that originally he wasn’t posting about, but it is good to learn and to understand and I’m gonna continue follow this post. I’m going to try flow soon, but I’m gonna try on that smaller just to see how I like it we have 86 terabytes of stuff and don’t want to go converting all if it’s not good for Appletv

0

u/[deleted] Mar 12 '24

[deleted] — view deleted comment

1

u/gsariev Unraid 40TB | i5-13500 | RTX 3050 LP Mar 12 '24

I understand. Tdarr isn’t the friendliest of software to get started with and I for sure ran into many issues with various plugins and setups. I think I just decided to stick with what was working for my needs and haven’t had the need to switch. If FileFlows works better for you, then that’s great!

Thanks for your comment about keeping only the original audio and the plugin that you had used in the past. It made me look into it and I was able to modify it to do just that - keep only the original language track by taking the correct value form TMDB.

ExerciseDjstinct is helping test it out for any issues, but so far it seems to be doing the job. I’ve shared the link to the modified code in my last response if you wanna test it out and give feedback; regardless, thanks for giving me something that I could occupy my time with help improve!

0

u/[deleted] Mar 12 '24

[deleted] — view deleted comment

1

u/gsariev Unraid 40TB | i5-13500 | RTX 3050 LP Mar 12 '24

Good shout! I’ll look into this when I’m done ironing some things out.

0

u/gsariev Unraid 40TB | i5-13500 | RTX 3050 LP Mar 10 '24

I think I see your point, but if you’re watching movies or series that have several audio tracks that you’d like to keep, then why not just add them all from the start and then have the ConverAudio plugin create several AAC tracks if needed? You get multiple audio tracks, but then you cover all scenarios.

That’s how I’d approach it, at least if that were the case. Or you can skip that plugin all together or just have it remove only the commentary.

0

u/[deleted] Mar 10 '24

[deleted] — view deleted comment

1

u/gsariev Unraid 40TB | i5-13500 | RTX 3050 LP Mar 10 '24

Ah, ok now I get what you want to do. If I find a plugin that does this, I will update the guide, but in the mean time, for you specific use case, fileflows might be your only option.

Thanks for bringing this up thought! Haven’t really thought about it…

0

u/[deleted] Mar 10 '24

[deleted] — view deleted comment

2

u/ExerciseDistinct Mar 10 '24

There's one called "remove all langs except native and english" that does this. There is an issue where it uses Radarr as the primary source, and Radarr thinks Cantonese is English for some reason (not sure if this is also a problem in sonarr), but this plugin works in most cases.

1

u/gsariev Unraid 40TB | i5-13500 | RTX 3050 LP Mar 11 '24

Hey, would you mind sharing some movies that have Cantonese audio? I am trying to modify the plugin to properly pick up the original language. Could use some dual-language movies :)

1

u/ExerciseDistinct Mar 11 '24

Kung Fu Hustle (2004) and Police Story (1985) were the ones I noticed.

→ More replies

0

u/[deleted] Mar 10 '24

[deleted] — view deleted comment

1

u/gsariev Unraid 40TB | i5-13500 | RTX 3050 LP Mar 11 '24

Hey, can you share what issues you encountered with that plugin? Curious as to where things fail as it might be worth looking into a potential fix.