PMS on Mac Post Processing Script Help

Hey all. I’ve been a long time Plex user, but I’m a recent convert from Tablo to Plex Live TV/DVR. I’ve been looking pretty closely at ways to make my recordings a bit smaller, but the option to transcode while recording is bringing my 2014 Mac Mini to a crawl. I use it as a home server so Plex isn’t the only thing running.

So I’ve been looking at post processing scripts and came across this one that looks to meet my needs. My question is probably a stupid one, but my experience with scripting is less than minimal. Since this script was originally written to run on a Linux server, is this a simple plug and play scenario or will I need to change filepaths? Specifically, it calls for resources in /usr/lib/plexmediaserver/Plex which doesn’t seem to exist on my Mac.

I’m not running a mac server but according to this article it appears that you can run a bash script on Mac OS.

You will obviously need to make the script executable and update the script to point to the right folders since it points to the wrong folder. I believe the resources folder is located here on the Mac: ~/Library/Application Support/Plex Media Server/

Thanks! I think I’ve changed the links to point to the right places, but I’m getting an error that it can’t find the libmpeg2video_decoder.dylib library despite being pointed to the folder where it resides. I’d appreciate any help getting it to work as I’m at a loss.

You can give a try to this script if you want.

I’ve use it on Mac and Ubuntu without any problem

I was just looking at that one. The one I’ve been working on is a derivative of nebhead’s.

Would you mind sharing the changes you had to make for it to work on Mac? I’m thinking I’m getting the file paths right, but not positive after the issues I’ve had thus far.

I’ve only changed the temporary folder path and I added the full for the ffmpeg command. Beside that, it was working as is.

I ended up doing the same thing. I took the things I liked from a bunch of scripts and mashed them together.

What is the exact error you are getting? I am wondering if the path isn’t written in a way the script likes. For example, sometimes I got errors when I used ~/‘some folder’ vs /home/‘some user’/‘some folder’.

It just can’t find the library. You may be on to something. I’m definitely using the ~/folder approach. Going to go back in and type out the full path to see if that helps.

Thanks! If I can’t get the other one to work, I may go back in and use nebhead’s. I’m liking the other one because it allows for audio passthrough.

Alright. I changed the file paths and I’m still getting an error that stops it from working. I’m thinking it comes down to this error.

-printf: unknown primary or operator

It’s in the line trying to access libmpeg2video_decoder.dylib so my suspicion is that this is causing the issue with finding the library.

Any ideas on a fix?

Try changing “-printf” to “-print”. It appears that the find command in Mac OS doesn’t have an option of “-printf”. The only options are “-print” or “-print0”. I believe it is only listing the names of the files found.

That’s taken care of that error. I’m thinking the issues I’m seeing center around this line.

CODECS="$(find “$FFMPEGLIBS” -name “libmpeg2video_decoder.dylib” -print “%h\n”)"

FFMPEGLIBS is a predefined filepath that points to the Plex Codecs folder. The last error I got was this one.

find: %h\n: unknown primary or operator

Thanks for all your help on this.

I am not by a computer right now but try adding a % Infront of the n.

Thanks again for working through this with me. At this point I’m just excited to be learning more about bash and finding a solution.

We’re getting closer. After looking at things a bit more closely, I figured out that the lines I was struggling with were essentially just making sure the codec I needed was there. Since I know it is, and I know the filepath, it was unnecessary. I commented that section of code out and it got rid of the error and started the analysis of the video as it should.

Now I’m running into the errors below during the actual transcoding process which grinds everything to a halt once again.

Unrecognized option ‘preset:v’.
Error splitting the argument list: Option not found

Here’s the line that seems to be triggering the error.

-c:v h264_nvenc -b:v ${BITRATE}k -maxrate:v ${BITMAX}k -profile:v high
-bf:v 3 -bufsize:v ${BUFFER}k -preset:v hq -forced-idr:v 1 ${DEINT_CUDA}
${AUDIOPARMS} \

It looks like you are supposed to select a preset for the quality of the video transcode some where but I can’t figure out where it is. What do you have selected on the transcode option in Plex?

I’m not sure why though because I thought this script automatically selects the quality based on the bitrate. Sorry. We may have to experiment. This is a little beyond my skills.

I think I’m going to swipe the transcoding language from this script and see if I can merge them somehow since this one’s been known to work.

From what I can tell, the one I’m working with is built off of that one anyway. I just like some of the extra features it adds if I can get it working.

Nice. That is what I ended up doing. I merged a bunch of bash scripts together and added a little language of my one. It was really fun. By the way if you find a script that has a good way to add a skip commercials to the video, please let me know because that is my next project.

By the way, if you have HandBrakeCLI installed it is pretty easy to write a script to transcode a video. It does a pretty good job.

Please let me know how things go.

I’ll keep you posted. Probably not going to get a chance to really work on it for a few days.

Commercial skip is part of what was added to this script that made me want to get it working. Supposedly it puts chapter markers at the commercials when it’s running well.

Alright. After messing around with things a bit, I was finally able to get the nebhead script running in full and the cedarrapidsboy script running in part using ffmpeg. The commercial skipping chapter markers on the second script never worked for me. I couldn’t get anything to work with Handbrake or the Plex Transcoder. The quality of the finished product is solid and significantly smaller.

All that being said, at this point I don’t think it’s worth it for me to use regularly just because of the amount of time it takes to process the recordings.

For half hour programs it’s not a huge deal, but I like to record and watch football games and transcoding a three hour long game takes almost as much time as the game itself. Makes it impossible to watch in a timely manner.

What I may do is save the script and bulk process the videos I want to keep on the DVR long term after they’re done recording while letting everything that comes and goes on a heavier rotation record in it’s native format.

I wish there was a setting that let you selectively apply the post processing script to specific recordings. But, oh well.

Anyway thanks for all your help!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.