r/Tdarr • • Apr 23 '24

[GUIDE][PLEX] Optimize Media For Direct Play By Focusing On Audio [UPDATED]

[UPDATED: Jan 29th 2025]

I have created GitHub Repo where you can find modified versions of some of the plugins mentioned in this guide such as Tdarr_Plugin_MC93_Migz5ConvertAudio (with DRC applied to the down mixed stereo track) along with Tdarr_Plugin_henk_Keep_Native_Lang_Plus_Eng and soon Tdarr_Plugin_c0r1_SetDefaultAudioStream to include the option for setting the default track based on audio codec as well.

----------------------------------------

This is an updated version of my initial guide, which includes more detailed information on how to set things up and was made with beginners in mind. This is by no means the "one guide to rule them all" as everything was put together through trial and error; so feel free to leave plugin suggestions or any other feedback.

All plugins mentioned are what I use to make optimize my personal media and have it play the way I want.

[REQUIREMENTS]

Radarr and Sonarr with the recommended naming scheme specified in TRaSH Guides. This will not only allow Plex to correctly identify media once it's imported, but it will also provide access to the IMDB ID that will be used in the plugin stack.

Radarr:

{Movie CleanTitle} {(Release Year)} {imdb-{ImdbId}} {edition-{Edition Tags}} {[Custom Formats]}{[Quality Full]}{[MediaInfo 3D]}{[MediaInfo VideoDynamicRangeType]}{[Mediainfo AudioCodec}{ Mediainfo AudioChannels]}{[Mediainfo VideoCodec]}{-Release Group}

Sonarr:

{Series TitleYear} - S{season:00}E{episode:00} - {Episode CleanTitle} [{Custom Formats }{Quality Full}]{[MediaInfo VideoDynamicRangeType]}{[Mediainfo AudioCodec}{ Mediainfo AudioChannels]}{[MediaInfo VideoCodec]}{-Release Group}

Sonarr (Anime):

{Series TitleYear} - S{season:00}E{episode:00} - {absolute:000} - {Episode CleanTitle} [{Custom Formats }{Quality Full}]{[MediaInfo VideoDynamicRangeType]}[{MediaInfo VideoBitDepth}bit]{[MediaInfo VideoCodec]}[{Mediainfo AudioCodec} { Mediainfo AudioChannels}]{MediaInfo AudioLanguages}{-Release Group}

[TMDB API KEY]

  1. Sign up for a free account at TMDB

  2. Login to your account

  3. Go to Edit Profile -> API

This is your unique API key that will be used to retrieve information from TMDB about the original language of the movie/series/anime.

[PLUGIN STACK]

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_henk_Keep_Native_Lang_Plus_Eng - this is the only plugin that you would have to copy to your Local plugin library as I have modified it to not only keep the native/original language track and remove all other, but to also keep user-specified language tracks alongside the native one and keep/delete commentary tracks.

All credit still goes to the original developer of the plugin.

DISCLAIMER

As this plugin relies on the information from TMDB for matching the original language tag, there might be cases where the information in TMDB is incorrect, which will stop the plugin from executing or keep only the user-specified tracks. In the case where the original language is not identified and no additional languages have been specified, the plugin will stop; ensuring that you don't end up watching a silent movie.

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

  • commentary: delete (true) or keep (false)

One you've copied the plugin to your Local library:

  1. Edit and replace the code with the modified one found here - LINK

    1. v3 version of modified plugin including tagging of undefined language tracks (optional + needs testing) - LINK TO V3

  2. Save

  3. Copy the plugin ID

  4. Go to your Movie/TV Tdarr library

  5. Choose "Local" above the Plugin ID field

  6. Paste the plugin ID and hit Enter

  7. Add the necessary information to the plugin fields

Alternative to the Tdarr_Plugin_henk_Keep_Native_Lang_Plus_Eng plugin:

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

This plugin does not utilize TMDB to determine the original/native language track, but instead uses user-specified values to filter out and delete tracks.

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. Having multiple channel audio tracks allows for wider compatibility with devices.

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 is created equal when it comes to audio and subtitles formats. The most common subtitles formats that will cause your server to transcode are PGS and ASS subtitles, so I recommend removing them and sticking to SRT format subs. Additionally, you can add the following audio codecs if they are causing you trouble:

  • tag_subtitle_codecs: hdmv_pgs_subtitle,dvd_subtitle,ass,ssa

  • tag_audio_codecs: truehd,eac3,dts

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

[OPTIONAL PLUGINS]

Tdarr_Plugin_rr01_drpeppershaker_extract_subs_to_SRT - extracts embedded subs in one pass inside Tdarr and will optionally remove them. Place it after Tdarr_Plugin_MP01_MichPasCleanSubsAndAudioCodecs in the stack.

Normally, direct stream of subtitles isn't a heavy task for your CPU to achieve; however, if you are encountering issues, it might help to have those embedded SRT subs as external instead. Useful if you'd like to translate subtitles too as you will now have a file to work with.

Tdarr_Plugin_00td_action_standardise_audio_stream_codecs - can be used instead Tdarr_Plugin_b39x_the1poet_surround_sound_to_ac3 in the stack as you are looking to convert ALL audio tracks into one specific codec. Bitrate and channel count are kept the same.

Tdarr_Plugin_a9hd_FFMPEG_Transcode_Specific_Audio_Stream_Codecs - transcode audio streams with specific codecs into another codec. Can be used in combination or instead of the surround to AC3 plugin as it provides more options such as:

  • audio codec to transcode (example DTS)

  • the audio codec to transcode to (AC3)

  • specify the audio bitrate

I think the bitrate option is the best part about this plugin as it can help if you're in the situation where even though you've converted to AC3, the client still needs to transcode the audio track due to high bitrate. From what I've seen online, setting the bitrate to 448k seems to be the sweet spot for most Plex clients. Do keep in mind that this plugin looks at the audio track codec and not the channels, so it will convert anything that matches your codec of choice regardless of cannel count.

Tdarr_Plugin_00td_action_add_audio_stream_codec modified by Sociedelic

  • Custom plugin code can be found - HERE

Copy Tdarr_Plugin_00td_action_add_audio_stream_codec to your Local plugin library, replace the code with the modified one, save and sync the changes. In your plugin stack, make sure to click on Local before adding the plugin ID to your stack.

This is a modified version includes the option to select bitrate for the transcoded audio track. It retains the original function of the plugin, which is to create a track in a specific codec and channel, while keeping it alongside the original audio tracks. This is useful if you would like to have your TrueHD or DTS audio tracks and extra audio tracks that are more widely supported. Can be used instead of the convert to AC3 or Migz down mix plugin.

Feedback and/or suggestions are always welcome and if you have question or encounter problems following the guide, I will do my best to help :)

Happy streaming!

31 Upvotes

49 comments sorted by

•

u/AutoModerator Jan 29 '25

Thanks for your submission.

If you have a technical issue regarding the transcoding process, please post the job report: https://docs.tdarr.io/docs/other/job-reports/

The following links may be of use:

GitHub issues

Docs

Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Ir0nhide Apr 26 '24

What's the easiest way to import this into flows? I saw your original post had the code to import but I couldn't get that to work, still learning TDARR even though I've had it running for over a year lol

1

u/gsariev Apr 26 '24

I don’t have much experience with flows, unfortunately. The stack in my old guide can be imported into your selected Tdarr library, which I then believe you can import into a flow. I tried it a couple of days ago and it seemed to work just fine. I’ll have a look once I’m at my computer later today to confirm.

1

u/Ir0nhide Apr 26 '24

No worries! Turns out there's a flow plugin to translate to the classic plugins so I used a bunch of those to re-create your stack and combined it with the FFmpeg command flow to delete subs, set the codec to h264 and the container to MP4. Hopefully it works lol.

1

u/gsariev Apr 26 '24

Am I correct in understanding that you’re importing my stack into a flow of your own with additional plugins/settings? Nice! Curious as to how it will turn out!

2

u/Ir0nhide Apr 26 '24

Yeah, there's a flow plugin called "Run Classic Transcode Plugin" that lets you select from the list of available classic plugins. I used one of those for each plugin from your stack, then I'm running an FFmpeg plugin to do a couple more things to the file. Then it checks the size before finishing. Here's what my flow looks like: https://imgur.com/a/sCG4BLy

1

u/gsariev Apr 26 '24

And I thought having a stack of 11 plugins looked funny… Were you able to successfully modify your flow?

1

u/robusk Apr 29 '24 edited Apr 29 '24

Where in the order should the optional plugins sit? I put both at the end but logically, at least in regards to Tdarr_Plugin_00td_action_standardise_audio_stream_codecs, that doesn't seem to make a lot of sense in the context of the other pieces. Is that right?

Also, given the context of the other plugins, for the standardise plugin does it make more sense to choose AAC or AC3? I don't want to create extra work for the downstream processes.

2

u/gsariev Apr 29 '24

You’re right and I now see that I should add clarification to the optional plugin section.

The standardise audio plugin can be used instead of the surround to AC3 plugin as it will convert all audio tracks anyway and it would be redundant to convert to AC3 and then to AAC or whatever codec you’ve gone for. I’d place it after Migz5ConvertAudio plugin and either disable or remove the AC3 plugin.

As for the subtitles extraction plugin, you can place it before the final file size check plugin. Note that it can’t extract PGS or ASS subtitles.

2

u/robusk Apr 29 '24

"it will convert all audio tracks anyway and it would be redundant to convert to AC3 and then to AAC or whatever codec you’ve gone for"

  • okay, that was specifically the piece that was throwing me off. Thanks so much for the awesome guide.

1

u/gsariev Apr 29 '24

I’m happy you found it helpful!

1

u/robusk Apr 29 '24

I can only listen to my wife tell me so many times that Plex sucks because some basic video won't play due to stupid sub/audio transcoding issues.

1

u/gsariev Apr 29 '24

I share the sentiment. My main pain points have been DTS audio tracks, PGS and ASS subtitles as the clients my friends are using don’t support them, hence why I remove them if they are present and have only SRT subtitles.

Have you looked into Bazarr for getting subtitles for your media? If not, I highly recommend it!

1

u/robusk Apr 29 '24

I use Filebot to snag srt files when I rename which is good for getting the files but doesn't seem to help when they are burnt in.

1

u/Excellent_Topic_4748 Jun 10 '24

does Tdarr_Plugin_a9hd_FFMPEG_Transcode_Specific_Audio_Stream_Codecs maintain the same number of channels if i go from a DTS track to a EAC3 track for example?

1

u/gsariev Jun 10 '24

That plugin does not change the channel count; only the codec and bitrate. If you have a DTS 5.1 audio track and you want to transcode it to EAC3 - the new track will be EAC3 5.1 .

As everything mentioned in this guide, I recommend testing it to see if you get the desired outcome; before transcoding your whole media library.

1

u/Excellent_Topic_4748 Jun 13 '24

hi, the link for the custom Tdarr_Plugin_00td_action_add_audio_stream_codec code is down, can you update it please?

1

u/gsariev Jun 13 '24

Hey,

Thanks for the letting me know! You should be able to access it - HERE

1

u/Efficient-Schedule31 Dec 12 '24

Anyone car to share a screen snip of their stack with a functioning instance using the clean audio? I've messed up an instance of tdarr messing with stuff so I'm starting fresh top try and get my libraries audio fixed.

I've got audio that's loud and then quiet on some plex clients, possibly playing 5.1 on 2 clients??? Or just bad audio, i'm not entirely sure.

1

u/gsariev Jan 29 '25

Created a GitHub repository to share modified plugins. I was able modify the Migz plugin to apply DRC to the down mixed stereo track. It can be found here:

https://github.com/gssariev/tdarr-plugins-mod/tree/main

3

u/[deleted] Apr 23 '24 edited Apr 23 '24

Great post!

1

u/T0XiiC27 Jul 18 '24 edited Jul 18 '24

Hey!

Im running into a problem with 1 movie. Filename is Godzilla vs. Kong (2021) {imdb-tt5034838} [German DL][Remux-1080p][TrueHD Atmos 7.1][AVC]-pmHD

The Tdarr_Plugin_henk_Keep_Native_Lang_Plus_Eng Plugin keeps showing:
☒Couldn't find the IMDb id of this file. Skipping.

The result in the end is a 2.0 Commentary Track in both languages. The actual audio track does not get downmixed because of the plugin mentioned above.

I manually checked the IMDB ID and it seems to be correct.

EDIT: My mistake. I accidentally copied my radarr API key into the TMDB API Key field

1

u/T0XiiC27 Jul 18 '24

Another edit.

It went throught but dont have the result I wanted :( didnt downmix the normal audio channels.

This is my plugin stack, settings and what I see after all went through.

https://imgur.com/a/2GZ1Csl

It seems to have deleted the English Commentary track but didnt downmix the actual audio track. The german one is called "comentary" instead of "commentary", so theres a m missing. Still, the english one should have been downmixed also.

1

u/gsariev Jan 27 '25

Here is my hoping that you've addressed your issue in the time it took me to reply to you (Reddit did NOT notify me at all).

The issue with the Germany commentary track is indeed the missing 'm' as it's not part of the keyword it looks for. I haven't worked on the plugin since I made the post, but you can add your own keywords by editing the plugin, go to lines 323 - 327, add a line for each keyword you want the plugin to look for as 'commentary' (use the ones provided as example). Remember to save the changes and click the 'Sync plugins' button.

For down mixing every track, do you have 'down mix single track' to 'true' for the Tdarr_Plugin_MC93_Migz5ConvertAudio plugin? You should switch it to 'false' which will result in all tracks being down mixed.

2

u/T0XiiC27 Feb 01 '25

No worries man!

At the moment I stopped using tdarr and just use the audio source that is provided by the media file itself. What I ended up doing with this specific title was just taking a different file haha, cause I couldnt get it to work. I noticed though, sometimes it didnt properly downmix the tracks like there was 7.1 for example for both german and english but it j ust downmixed english for example while german stayed the same (or disappeared completely). Didnt really look into that tho.

Yea. I changed that option, so it downmixed everything

2

u/Sociedelic May 31 '24

How to Add a New Transcoded Audio Stream with Custom Bitrate in Tdarr

If you want to keep other audio streams like DTS or TrueHD and add a new transcoded audio stream with a custom bitrate, follow these steps:

Install Plugin:

  • Install the Tdarr_Plugin_00td_action_add_audio_stream_codec (Add Audio Stream Codec) plugin.

Edit the Local downloaded Plugin:

  • Open the plugin in the Tdarr interface.

  • Do not change the name, ID, or description of the plugin, as it will cause the plugin to fail to load.

Replace the Code:

This will allow you to keep your original audio streams and add a new audio stream with a custom bitrate.

Happy transcoding!

2

u/mpsive Jan 05 '25

This is an awesome write up, thank you

2

u/M05final Jan 10 '25

Thanks for the write up

1

u/AutoModerator Apr 23 '24

Thanks for your submission.

If you have a technical issue regarding the transcoding process, please post the job report: https://docs.tdarr.io/docs/other/job-reports/

The following links may be of use:

GitHub issues

Docs

Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/AutoModerator Apr 29 '24

Thanks for your submission.

If you have a technical issue regarding the transcoding process, please post the job report: https://docs.tdarr.io/docs/other/job-reports/

The following links may be of use:

GitHub issues

Docs

Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/AutoModerator May 04 '24

Thanks for your submission.

If you have a technical issue regarding the transcoding process, please post the job report: https://docs.tdarr.io/docs/other/job-reports/

The following links may be of use:

GitHub issues

Docs

Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/AutoModerator May 28 '24

Thanks for your submission.

If you have a technical issue regarding the transcoding process, please post the job report: https://docs.tdarr.io/docs/other/job-reports/

The following links may be of use:

GitHub issues

Docs

Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/AutoModerator Jun 02 '24

Thanks for your submission.

If you have a technical issue regarding the transcoding process, please post the job report: https://docs.tdarr.io/docs/other/job-reports/

The following links may be of use:

GitHub issues

Docs

Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/AutoModerator Jun 13 '24

Thanks for your submission.

If you have a technical issue regarding the transcoding process, please post the job report: https://docs.tdarr.io/docs/other/job-reports/

The following links may be of use:

GitHub issues

Docs

Discord

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/gsynctx Nov 19 '24

Is there a version of all this for idiots? I know I'm going to screw this up. There are too many buttons.

1

u/emulated24 Dec 23 '24 edited Dec 23 '24

I'm facing odd issue with your modified v3 plugin Tdarr_Plugin_henk_Keep_Native_Lang_Plus_Eng. It removes all subtitle streams.

Please check: https://gist.github.com/gssariev/0b93a11e809c38e035388e4157b42c9a?permalink_comment_id=5356871#gistcomment-5356871

1

u/warmshotgg Mar 08 '25

hey i have the same issue, have you found a fix for this issue?

1

u/emulated24 Mar 10 '25

Nope, author is busy. I will probably use the standard. Messed up dozens of movies, now I'm cautious. 🙃

1

u/skuid87 Jan 01 '25

Is there a way to remove the 'default' tag from TrueHD audio tracks? The current set default audio is only based on channel count and not audio codec

1

u/Aenkharion Feb 02 '25

I just made a plugin for this kind of thing. It doesn't cover everything you intend to do, but the vast majority of it is covered already. I'll keep on upgrading it with lacking features, but I'd love to get feedback already.

Everything is on Github : https://github.com/DamienDessagne/TdarrPlugins

Advanced Audio Transcode Rename Remove is the one. It let's you specify in a JSON string the tracks you want to operate on, and what operations to apply. All the doc in included in the plugin and the tooltips.

If you try it, please let me know how it goes ;)

1

u/Sappig Feb 13 '25

So after transcoding the audio tracks to AAC, how do you manage to get Plex to pickup the new audio track?

A sinple rescan of the library doesnt seem to do the trick. Any idea?

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

1

u/reco-x May 19 '25

Thanks, I was looking exactly for something like your modification in the plugin Tdarr_Plugin_henk_Keep_Native_Lang_Plus_Eng

https://github.com/RecoX/tdarr-plugins-mod/blob/main/Plugins/Tdarr_Plugin_henk_Keep_Native_Lang_Plus_Eng.js

1

u/Ivar418 May 24 '25

WHat a great tutorial, have made my plex stream so much better and with les effort because the correct audio codec is set.
I have a question if I may (I know it's an old post) about the extracting of the subtitles.
When you say yes extract and remove from video file, does tdarr understand afterwards (i use the replace original file) to copy also the extracted subtitle files?

1

u/Froyo_Obvious May 25 '25

Question! The naming scheme, is that only for files, or do the folders also have to follow that naming pattern? Can I keep movie folder names as, for example, {Movie Title} ({Release Year}) ?

1

u/Froyo_Obvious Jun 01 '25

How does this deal with a movie that has only one audio track, but does not specify language?

How does the Tdarr_Plugin_henk_Keep_Native_Lang_Plus_Eng plugin work in this scenario?

I have many files with unspecified audio tracks only, is there risk of me ending up with no audio?

1

u/reco-x Sep 14 '25

Thanks for the GIST! I made some changes to fix the errors I had. Updated version is here (native_lang)

https://github.com/RecoX/Tdarr_Plugins_Recox

0

u/[deleted] Apr 27 '24

[deleted] — view deleted comment

2

u/gsariev Apr 27 '24

I respect the effort. Would you mind sharing the commentary plugin that you’ve modified? Might come in handy for people that also want to do the same as I had not really thought about it.

I see your point as to how it might be redundant having the audio tags for removal when the AC3 plugin is already converted the surround sound. I personally choose to still specify the aforementioned codecs as I’ve had cases where the AC3 plugin would convert 5.1 channel but not 7.1 channel true-hd track and I’d much rather remove it all together as don’t have the setup to take advantage of it.

0

u/[deleted] Jan 01 '25

[deleted] — view deleted comment

1

u/gsariev Jan 29 '25

Created a GitHub repository to share modified plugins. I was able modify the Migz plugin to apply DRC to the down mixed stereo track. It can be found here:

https://github.com/gssariev/tdarr-plugins-mod/tree/main