Cayars - Setup walk through and some tips and tricks

I have been roaming through this thread and im trying to figure out what config i should use to convert my media so that i can stream over the net without transcoding with the less lost of quality possible. I saw many post with configs and explanations but since some are old, maybe things have changed. I have mkv’s, mp4’s and avi’s.

I also wanted to know between this and the optimize function in plex, on a scale from 1 to 10 how much better is this method? Besides the fact that it is done outside plex.

Also just a recommendation to @cayars , maybe this script should have its own thread so we dont have to search for script related post in between other post.

Thanks!

@cayars any updates on your distributed transcoding project? Last post I saw from you on this was back in January so just wondering if you have had time to work on it. Thanks in advance.

@almontef said:
@cayars any updates on your distributed transcoding project? Last post I saw from you on this was back in January so just wondering if you have had time to work on it. Thanks in advance.

I’m pretty sure Plex themselves are coming up with something similar… In one of the plex roundtables they mentionned, without going into details, that they would help content discovery for people with multiple servers. My guess is they will merge similar content into 1 item in your library and then will stream from whichever server is available/fastest/less used/whatever… so you could probably set up multiple servers with either the same media or different media and they could all show up as one. That could allow you to use different servers to transcode different stuff… not the same, but close enough.

Just my uneducated guess though, they really didn’t say what their plans were…

@don.alcombright said:
@benamira:

First, just want to say this is all @cayars and @MovieFan.Plex work, they were gracious enough to help me out.

MP4 Converter Details and How to Install
https://forums.plex.tv/discussion/comment/931888/#Comment_931888

autoProcess.ini
you can read more about this here sickbeard_mp4_converter, but the only settings in this tutorial that matters are:

output_directory =

  • blank will place it in the same location the file is found
  • fill this out if you want it to be a different location

delete_original =

  • True/False

audio-language =

  • blank will keep all audio formats
  • 3 letter country code, eng by default means it will strip out ALL OTHER AUDIO other than English.

Performance Tweaking
under Convert\Converter\ffmpeg.py change to the following:

  • cmds.extend([‘-crf’, ‘18’])
  • cmds.extend([‘-threads’, ‘1’])
    this will increase the quality and also only allow it to run on one core per process, again helping with quality.

SQL Scripts and Creating your batch files to run the process

  • First and foremost you are using your plex database, and even though it is just select statements, ALWAYS make a backup or just run the scripts against a backup like I did.
  • Download and install SQLite3 binaries onto your machine from here. You will want SQLite3 and all the files below in the same directory.

Remember, the below scripts don’t do the work, they just create batch files for you to run that will do the work. Depending on what OS/how your structure is setup you might need to modify the output of these to run. For example, Plex stores a record of the file I need like ‘/tvseries/Adventure Time/Season 01/Adventure Time - S01E04 - Tree Trunks.mp4’, I needed to find and replace the slashes and also add an ip to the beginning. Nothing major but just something to notice before you kick it off.

This will list all movies without English Audio, meaning no language is listed as well
.open ‘[PATH_TO_PLEX_DB]\com.plexapp.plugins.library.db’
.output “1_Non-English_Audio_Files.bat”
select mp.file from media_parts as mp inner join media_items as mi on mi.id = mp.media_item_id inner join metadata_items as mdi on mdi.id = mi.metadata_item_id where mp.id not in (SELECT media_part_id from media_streams where stream_type_id = 2 and language = “eng”) and mdi.metadata_type < 5 order by mp.file;

OR This will list all movies without English Audio but also not list no language, assuming these are english, your choice.
.open ‘[PATH_TO_PLEX_DB]\com.plexapp.plugins.library.db’
.output “2_No_Default_Or_English_Audio_Files.bat”
select mp.file from media_parts as mp inner join media_items as mi on mi.id = mp.media_item_id inner join metadata_items as mdi on mdi.id = mi.metadata_item_id where mp.id not in (SELECT media_part_id from media_streams where stream_type_id = 2 and (language = “eng” or language = “”)) and mdi.metadata_type < 5 order by mp.file;

See Autoprocess.ini section for language changes

MP4’s that aren’t “web optimized for streaming”, MOOV_ATOM
.open ‘[PATH_TO_PLEX_DB]\com.plexapp.plugins.library.db’
.output “3_Web_Optimize_Files.bat”
SELECT ‘[PATH_TO_PYTHON]\Python [PATH_TO_MP4_CONVERTER]\manual.py -a -i "’ || file || ‘"’ FROM media_parts join media_items
on media_parts.media_item_id=media_items.id
where container=‘mp4’ and optimized_for_streaming <> 1
order by file;

Find 10 Bit Videos to fix using straight up ffmpeg instead of the MP4 Converter script
.open ‘[PATH_TO_PLEX_DB]\com.plexapp.plugins.library.db’
.output “4_10Bit_Files.bat”
select ‘[PATH_TO_MP4_CONVERTER]\ffmpeg -i "’ || file || ‘" -c:v libx264 -c:v libx264 -preset slow -crf 18 -acodec copy -map 0 -profile:v high -level 4.0 “C:\convert\done' ||
replace(file, rtrim(file, replace(file, '', ‘’ ) ), ‘’) || '”’
FROM media_parts join media_items
on media_parts.media_item_id=media_items.id
where media_parts.extra_data like ‘%AVideoProfile=high%%2010%’
order by file;

Make a list of all non-MP4’s.
.open ‘[PATH_TO_PLEX_DB]\com.plexapp.plugins.library.db’
.output “6_Complete_File_List.bat”
SELECT ‘[PATH_TO_PYTHON]\Python [PATH_TO_MP4_CONVERTER]\manual.py -a -i "’ || file || ‘"’ FROM media_parts join media_items
on media_parts.media_item_id=media_items.id
where container!=‘mp4’
order by file;

I just converted a few videos from mkv to mp4 but they are still transcoding when i play them via webplayer or android app…im i missing something?

my ini file:

[MP4]
ffmpeg = P:\apps\Convert\ffmpeg.exe
ffprobe = P:\apps\Convert\ffprobe.exe
output_directory =
output_extension = mp4
output_format = mp4
delete_original = True
audio-codec = ac3,mp3,dts,dca
video-codec = h264,x264
video-bitrate =
ios-audio = True
ios-first-track-only = True
audio-language = eng,fre,fra
audio-default-language = eng
audio-channel-bitrate = 256
subtitle-language = eng,fra
subtitle-default-language = eng
convert-mp4 = True
download-artwork = False
fullpathguess = True
tag-language = en
copy_to =
download-subs = False
move_to =
max-audio-channels =
tagfile = False
embed-subs = False
subtitle-codec = srt
video-max-width =
permissions = 777
relocate_moov = False
sub-providers = addic7ed, podnapisi, thesubdb, opensubtitles

Server log should indicate why it’s transcoding.

@astrofisher said:
Server log should indicate why it’s transcoding.

Thanks…it was because i put a limit on the Limit remote stream birate

Has anyone had luck running the converter in Linux or in a Docker?

Awesome thread by the way. cayars is the man. Got a way for us to donate?

@snayers said:
Has anyone had luck running the converter in Linux or in a Docker?

Awesome thread by the way. cayars is the man.

Yes, this works very well on the Asustor NASes, which are Linux based. I have a link in my signature for the edits required to make it happen. And I think I made at least one other reference to this in the thread, but 33 pages is a bit much to wade through… :slight_smile:

@cayars has a truly awesome setup. I’m humbled that he considers me a friend, honestly… :slight_smile:

Hello everyone!

Been away for a few months. Needed to take a break from the Plex forums because I was getting really annoyed and frustrated with multiple things on the Plex front.

My self imposed “time out” seems to have done me some good. :slight_smile: I’m no where near as frustrated as I was a few months ago.

I want to THANK all of you for keeping the thread going and helping each other.

I kinda of let the transcoding scripts go to the way side a bit (eg no updates to my stuff) hoping that Plex would be doing a better job with the newer functionality they had added to the server. I know for myself I still prefer the external conversion over what the server will do.

How do you guys feel? Still using these scripts? Want an updated version?

Carlo

Welcome back :slight_smile:

@cayars Thank you for all your effort and support. I’m just getting into this whole new world of Media Server and also looking at your custom solutions that will help me a lot.
I’m Just wondering, Do you have any topic about Music?. I’m Using MusicBrainz Fileboot and Headphones to manage the whole overall but there;s some missing keys like duplicated/ empty folders / Formats etc.
Any Help much appreciated.
Kind regards,

Thanks vanstinator

@carloslozada said:
@cayars Thank you for all your effort and support. I’m just getting into this whole new world of Media Server and also looking at your custom solutions that will help me a lot.
I’m Just wondering, Do you have any topic about Music?. I’m Using MusicBrainz Fileboot and Headphones to manage the whole overall but there;s some missing keys like duplicated/ empty folders / Formats etc.
Any Help much appreciated.
Kind regards,

Not really anythings that’s going to help you much. I’m doing pretty much the same as you.
If you’re using MusicBrainz to rename your files you shouldn’t end up with empty folders. You can still get duplicate songs if you have the same song in different formats however. Only real way around that is to convert all tracks to MP3 or similar before renaming things.

@cayars said:
Hello everyone!

Been away for a few months. Needed to take a break from the Plex forums because I was getting really annoyed and frustrated with multiple things on the Plex front.

My self imposed “time out” seems to have done me some good. :slight_smile: I’m no where near as frustrated as I was a few months ago.

I want to THANK all of you for keeping the thread going and helping each other.

I kinda of let the transcoding scripts go to the way side a bit (eg no updates to my stuff) hoping that Plex would be doing a better job with the newer functionality they had added to the server. I know for myself I still prefer the external conversion over what the server will do.

How do you guys feel? Still using these scripts? Want an updated version?

Carlo

Carlo,

Welcome back.

I started using your transcoding script and really like it. But I didn’t know how to automate that with sickbeard.
So I started using the sickbeard_mp4_automator which I think you customized (removing tags, adding 1st track aac) and such. And I tried to use your settings with the automator and it seems to be working but not sure 100% compliant with how you set up files.

Is there an easy way to set up your script to be called up by sickbeard?

The script is doing everything I would want with a file.
Leave MP4 to MP4.
Convert MKV to MP4.
Strip extra tags
Create 1st track aac
Leave multi-channel track in track 2
Strip subtitle to srt
download srt

Thanks,

Joe

Welcome back.

I stopped using them because of the apple TV issue where you would have 2 sounds tracks. For the most part it was working very well., but after I got one video playing 2 different tracks at the same time on the ATV, I stopped using them as I was converting and throwing away the original. I have just been piggy-backing off the built in optimization functionality, moving the file out of the directory and then back in. Not great, but a work-around.

WB Carlo!

Of course I’m still using the scripts, and sending people to this post or my own about converting or media types, etc. Yes, I’m ready for some updated scripts, if you are ready to send them out. I’ll modify them to work for Linux, and then get them zipped up for anyone that needs to use them on that platform. I’ve been having issues with H265 stuff, and I’m sure that’s due to the 10-bit depth of those files.

What I was thinking for this round is that we try and use the full version of sickbeard_mp4_automator so that people can more easily use it for the other purposes as well. If that causes problems we can strip it back down since anyone can always run two different versions as before.

Probably Python 3 so unicode has far less issues.

Going to need a couple of guys to explain better and help test the Apple TV 2 soundtrack issue which I believe was an issue in FFMPEG itself which we can upgrade to the latest version (but slower).

I’m playing around with it now to see how much work it is going to entail and what might still need customized for our purposes.

If a couple of you guys want to help beta test the new version let me know. I’m currently using it. :slight_smile:
Python 2 or 3 compatible (better unicode file names)
Fixes Apple audio problem with multiple tracks
full sickbeard_mp4_automator functionality with my typical settings

Still have a couple of smaller things I’m working on for Quality & Presets. I’m also going to test using GPU support for those who might want this functionality but I’d generally recommend against it since it won’t be as good as CPU encoding.

Yes, still using your script. :smiley:

Is it a new download? I’m logged into your FTP now and I see just convert.zip ATM…