Cayars - Setup walk through and some tips and tricks

@cayars said:

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

Carlo

Love the scripts!

While Plex does an admirable job of subtitles, the languages most files are encoded in leave much to be desired. Maybe we could add in a check for language in both mp4 and mkv files:

ffprobe.exe -v quiet -show_entries stream_tags -select_streams a:0 -of csv="p=0"

and then run a selective (as opposed to all encompassing remux):

    MP4Box.exe -lang 1=en-us -lang 2=en-us "%f"
    
    and/or
    
    mkvpropedit.exe %f --edit track:v1 --set language="eng" --edit track:a1 --set language="eng"

or something of the sort…

I’ll be putting a ā€œbetaā€ or testing version up soon and will let you guys know. I want to test a couple of more things first.

The new version will work slightly differently due to more functionality and we may need/want to modify the base scripts a bit.

JasonMeudt, with the newer version you can have it download subtitles for your movies/shows and keep them as SRTs. You can pull them out of the MKV/MP4 file or you can take the standalone subtitles and embed them in the converted files.

What I’m sort of working on with basic testing is detecting 10-bit files and converting them to 8 bit files even if they are already in AVC format. I might leave this for round two so as not to effect the basic functionality to much right out of the gate.

@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

I would love an updated version that fixes the setting all audio tracks as the default (so they get played concurrently) on iOS. Only thing I would really appreciate. Don’t feel obligated. You do you. :slight_smile:

I’m a doofus and don’t read. THANK YOU!

One suggestion I might make, Carlo… Document the Autoprocess.ini a bit so it’s a little more intuitive what options do what, or how to get something (such as audio tracks or subtitles in multiple languages.)

Another thing I can think is to have a ini for movies and one for TV shows, as some people put them into different folders, etc. as they are downloaded or ripped. We know they wind up in different folders before Plex gets them, in any case. But this is a non-issue if someone has a decent workflow for adding stuff.

@cayars said:

JasonMeudt, with the newer version you can have it download subtitles for your movies/shows and keep them as SRTs. You can pull them out of the MKV/MP4 file or you can take the standalone subtitles and embed them in the converted files.

I was more referring to the language tag of both the audio stream and the video stream of each file… While I have the subtitles taken care of, I only want forced subtitles and when the audio tag is not set (ā€œā€), Plex won’t use the forced version as a default.

As opposed to going through each file and remuxing without fail, either quering the database for the language tag ala:

.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 or language = "en-us" or language = "")) and mdi.metadata_type < 5 order by mp.file;

Or via cmdline query of the audio stream:

ffprobe.exe -v quiet -show_entries stream_tags -select_streams a:0 -of csv="p=0"

Simply converting everything is overly intrusive and remuxing mkv’s ā€œjust becauseā€ the language is not set to ā€˜eng’ or ā€˜en-us’ seems overkill as well.

If I understood the sql interrogatory better, it might make it easier for me to self correct a batch file…

I am in Carlo.

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.

I’ve added nearly full support for Nvidia decoding/encoding into sickbeard’s mp4 automator here - https://github.com/Collisionc/sickbeard_mp4_automator

Same as the original with better nvidia support, my changes are as follows – Just copying part of the README.md. :slight_smile:

Nightly builds from https://ffmpeg.zeranoe.com/builds/ will work with all added options except scale_npp.

scale_npp support requires the following:

  • CUDA Toolkit 8.0 - https://developer.nvidia.com/cuda-downloads installed on the pc using ffmpeg. Unfortunately there doesn’t seem to be a way to statically compile scale_npp support on Windows, and this is the only way to get the shared libraries so ffmpeg doesn’t complain about missing .dlls when loaded.
  • I created a fork of ffmpeg-windows-build-helpers and edited the build script so that it will add scale_npp to ffmpeg while compiling - https://github.com/Collisionc/ffmpeg-windows-build-helpers - Make sure to enable non-free libraries for scale_npp support

Using the gpu for decoding doesn’t change the overall speed of taking a file and encoding it via gpu to another format, but it does free the cpu so that it may be used for other things.

scale_npp may speed up downscaling resolution from 1080p → 720p, but I haven’t benchmarked it yet.

Brief explanation of added settings:

  • ā€˜qmin’ = minimum video quantizer scale (VBR) (from -1 to 69) (default 2) - Must be set when nvenc_rate_control is vbr_2pass or vbr_minqp.
  • ā€˜qmax’ = maximum video quantizer scale (VBR) (from -1 to 1024) (default 31)
  • ā€˜global_quality’ = Must be set when nvenc_rate_control is constqp
  • ā€˜maxrate’ = maximum bitrate (in kb/s). Used for VBV together with bufsize. (from 0 to INT_MAX) (default 0)
  • ā€˜minrate’ = minimum bitrate (in kb/s). Most useful in setting up a CBR encode. It is of little use otherwise. (from INT_MIN to INT_MAX) (default 0)
  • ā€˜bufsize’ = set ratecontrol buffer size (in kb/s) (from INT_MIN to INT_MAX) (default 0) - I usually set this to 5*average bitrate, but mileage will vary.
  • ā€˜nvenc_encoder_gpu’ = Selects which NVENC capable GPU to use for encoding. First GPU is 0, second is 1, and so on. Default is any
  • ā€˜nvenc_profile’ = h264 options include: baseline, main, high, high444p - default is main
  • ā€˜nvenc_preset’ = Options include: slow, medium, fast, hp, hq, bd, ll, llhq, llhp, lossless, losslesshp - default is medium
  • ā€˜nvenc_rate_control’ = Options include: constqp, vbr, cbr, vbr_minqp, ll_2pass_quality, ll_2pass_size, vbr_2pass - default is constqp
  • ā€˜nvenc_temporal_aq’ = (true/false) Improves output quality slightly, adds 2-5% extra processing time - default off
  • ā€˜nvenc_rc_lookahead’ = Number of frames to look ahead for rate-control (from -1 to INT_MAX) - default -1
  • ā€˜enable_nvenc_decoder’ = (true/false) Enable gpu decoding. Default is false
  • ā€˜enable_nvenc_hevc_decoder’ = (true/false) Enable GPU decoding of HEVC/VP9. Only supported by Geforce 950/960/1050/1060/1070/1080 and Pascal quadros. Default is false
  • ā€˜nvenc_decoder_gpu’ = Selects which NVENC capable GPU to use for decoding. First GPU is 0, second is 1, and so on. Default is any
  • ā€˜nvenc_hevc_decoder_gpu’ = Selects which NVENC capable GPU to use for hevc decoding. First GPU is 0, second is 1, and so on. Default is any.
  • ā€˜scale_npp_enabled’ = (true/false) Enables usage of NVIDIA Performance Primitives | NVIDIA Developer to resize video output resolution. Requires building ffmpeg yourself, as npp is currently a nonfree license. Default - false
  • ā€˜scale_npp_interp_algo’ = Which algorithm to use with scale_npp - Options include: nn, linear, cubic, cubic2p_bspline, cubic2p_catmullrom, cubic2p_b05c03, super, lanczos. Default - super

If you have multiple nvidia cards you can decode on one and encode on the other, but it doesn’t seem to speed up the process at all.
Decoding by itself does not count towards the nvenc 2 stream limit.

With a lot of tweaking I’ve gotten gpu encoding to look nearly as good as cpu encoding. Like most people, upstream bandwidth is the issue I run into, so I’ve re-encoded nearly everything in my library with the following settings in the autoprocess.ini file:

video-codec = nvenc_h264
video-max-width = 1280
video-bitrate = 4000
qmin = 17
maxrate = 6000
bufsize = 18000
nvenc_profile = high
nvenc_preset = slow
nvenc_rate_control = vbr_2pass
nvenc_temporal_aq = true
nvenc_rc_lookahead = 64
enable_nvenc_decoder = True
enable_nvenc_hevc_decoder = True

Completely ballparking it, the 4 Mbps output from nvenc appears to be ~equal in quality to 3.5 Mbps output from the cpu h264 encoder. If comparing dark scenes with a lot of black/grey colors, 4 Mbps from nvenc is probably closer to 3.25 Mbps on the cpu.

However, the speed difference is massive. I have a 1080 gtx and a i7 6900k, and when converting a 15~ megabit 1080p h264 file to 4 megabit 720p with those settings I get around 280 fps with the 1080, 40 fps with the cpu.

  • ā€˜scale_npp_enabled’ = (true/false) Enables usage of NVIDIA Performance Primitives | NVIDIA Developer to resize video output resolution. Requires building ffmpeg yourself, as npp is currently a nonfree license. Default - false
  • ā€˜scale_npp_interp_algo’ = Which algorithm to use with scale_npp - Options include: nn, linear, cubic, cubic2p_bspline, cubic2p_catmullrom, cubic2p_b05c03, super, lanczos. Default - super

Just to add a note, scale_npp requires that the input and output pixel formats be either yuv420p, nv12 or yuv444p. It will not work with any other pixel format.

The GPU decoder also only supports pixel formats with 420 chroma, so it will not work with yuv444p, yuv422p, etc.

I just added in handling for these restrictions, so it will no longer error out while running. It will just disable scale_npp/gpu decoding when it runs into those formats.

I did a search on Sonarr automation in this thread and I think I get how to set it up, but I’m not sure how to implement this into my workflow.
Workflow… Sonarr/deluge/seed folder/extract now/hardlink - move and rename to Plex dir.
Any ideas how I can stick the transcoding setup in here without it messing up my torrent seeds?

@cayars said:
I’ll be putting a ā€œbetaā€ or testing version up soon and will let you guys know. I want to test a couple of more things first.

You mentioned that your new version is/may be available in another post. Did I miss it since it is not on your FTP server?

@JasonMeudt said:

@cayars said:
I’ll be putting a ā€œbetaā€ or testing version up soon and will let you guys know. I want to test a couple of more things first.

You mentioned that your new version is/may be available in another post. Did I miss it since it is not on your FTP server?

I was also curious about this. I’ve been checking back often for links or details on the new version, but haven’t seen anything as of yet.

@jesseeverhart said:
I did a search on Sonarr automation in this thread and I think I get how to set it up, but I’m not sure how to implement this into my workflow.
Workflow… Sonarr/deluge/seed folder/extract now/hardlink - move and rename to Plex dir.
Any ideas how I can stick the transcoding setup in here without it messing up my torrent seeds?

Cayar’s script is a stripped down version of GitHub - mdhiggins/sickbeard_mp4_automator: Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library with ffmpeg already included in the download and a batch file to manually start the script.

The link above has support for Deluge or Sonarr post processing via python scripts, in which you can have it transcode everything automatically after Deluge has downloaded it. There are options to copy or move the encoded file out of the original folder, as well as not deleting the original for seeding purposes.

Basically you would tell Deluge to run DelugePostProcess.bat after downloading and it would take care of the rest.

@Collisionc said:

@jesseeverhart said:
I did a search on Sonarr automation in this thread and I think I get how to set it up, but I’m not sure how to implement this into my workflow.
Workflow… Sonarr/deluge/seed folder/extract now/hardlink - move and rename to Plex dir.
Any ideas how I can stick the transcoding setup in here without it messing up my torrent seeds?

Cayar’s script is a stripped down version of GitHub - mdhiggins/sickbeard_mp4_automator: Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library with ffmpeg already included in the download and a batch file to manually start the script.

The link above has support for Deluge or Sonarr post processing via python scripts, in which you can have it transcode everything automatically after Deluge has downloaded it. There are options to copy or move the encoded file out of the original folder, as well as not deleting the original for seeding purposes.

Basically you would tell Deluge to run DelugePostProcess.bat after downloading and it would take care of the rest.

I’m actually asking here after trying to make sense out of the mp4_automator setup guide.
I should have mentioned that.

After reading the guide again… am I supposed to Frankenstein Cayar’s setup with the mp4_automator autoProcess.ini? And tell it to not delete the original? Then the postSonarr.py script triggers Sonarr to hardlink/move and rename the transcoded version. Leaving the original as it was downloaded?
See why I’m confused?

@jesseeverhart said:

@Collisionc said:

@jesseeverhart said:
I did a search on Sonarr automation in this thread and I think I get how to set it up, but I’m not sure how to implement this into my workflow.
Workflow… Sonarr/deluge/seed folder/extract now/hardlink - move and rename to Plex dir.
Any ideas how I can stick the transcoding setup in here without it messing up my torrent seeds?

Cayar’s script is a stripped down version of GitHub - mdhiggins/sickbeard_mp4_automator: Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library with ffmpeg already included in the download and a batch file to manually start the script.

The link above has support for Deluge or Sonarr post processing via python scripts, in which you can have it transcode everything automatically after Deluge has downloaded it. There are options to copy or move the encoded file out of the original folder, as well as not deleting the original for seeding purposes.

Basically you would tell Deluge to run DelugePostProcess.bat after downloading and it would take care of the rest.

I’m actually asking here after trying to make sense out of the mp4_automator setup guide.
I should have mentioned that.

After reading the guide again… am I supposed to Frankenstein Cayar’s setup with the mp4_automator autoProcess.ini? And tell it to not delete the original? Then the postSonarr.py script triggers Sonarr to hardlink/move and rename the transcoded version. Leaving the original as it was downloaded?
See why I’m confused?

I had issues getting the sonarr part of the script to work, so instead of having sonarr control it, I had Sabnzbd post-process the script – SABPostProcess.py, and then after it converted the file it would send a signal to Sonarr that it should scan the folder to pickup the download. Under Sonarr, I had to disable Completed Download Handling, but left failed download handling on. It will give you warnings for this, but it works fine.

You should be able to get this same process to work with Deluge, but I’ve never used deluge so I can’t help you out much there. :frowning:

Make sure that you run the pip commands listed here - sickbeard_mp4_automator/README.md at master Ā· mdhiggins/sickbeard_mp4_automator Ā· GitHub

Also this - sickbeard_mp4_automator/README.md at master Ā· mdhiggins/sickbeard_mp4_automator Ā· GitHub

Create a copy of the autoProcess.ini.sample file that you get with sickbeard’s mp4 automator and rename it autoProcess.ini, after you do this, you can copy the settings from Cayar’s into that file, but also make the necessary changes so that it will work with deluge/sonarr.

@cayars said:

JasonMeudt, with the newer version you can have it download subtitles for your movies/shows and keep them as SRTs. You can pull them out of the MKV/MP4 file or you can take the standalone subtitles and embed them in the converted files.

I use SubZero for any subtitles since you can now specify to only retrieve ā€˜forced’ subs in the latest iterations.

Somehow, I feel I have been ā€˜linked’ to anything subtitle related in your scripts, and yet, I have only inquired as to the ability of changing the actual ā€˜language’ of the respective audio and video tracks within the various containers ala:

https://forums.plex.tv/discussion/comment/1318214/#Comment_1318214

With the inter-relation of subs and languages as it is, it may have been my inability to fully explain myself…

Anyone else seen this issue with this script? - requested unknown video codec x264

I’ve ran into it twice with 2 older shows (.avi).

x264 isn’t a video codec, it’s a video library that is used to convert streams into h264. You can remove x264 from the list of video-codec in autoprocess.ini

Getting this error. No clue what’s causing it…
An unexpected error occurred, processing of this file has failed
global name ā€˜exceptions’ is not defined

edit: Nevermind. I had changed relocate_moov to true. Then I used the search bar here and figured out why that was causing it.

is there any benefits in using sickbeard_mp4_automator VS handbreak ?

@TwistedEndz said:
is there any benefits in using sickbeard_mp4_automator VS handbreak ?

sickbeard_mp4_automator is made to automate. handbrake is for individual or batch conversion.
Although you can automate with handbrake. http://www.makeuseof.com/tag/watch-folders-convert-video-files-dropfolders-handbrake/

I’ve had zero luck setting up sickbeard_mp4_automator recently with my configuration.
I did happen to figure out a workaround using cayers script, a free folder watch app and a couple of batch files.