Cayars - Setup walk through and some tips and tricks

@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

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;

1 Like