Linux/Mac script for transcoding and adding to Plex

@amann180 - I can’t think of anything else that might fix it from my end. Sorry! But the solution of manually editing your transcode.db file the first time should work. Just delete all the show numbers you want to transcode, or add any that you want to skip.

@karlmitchell. I’m still trying to make it work! I was reading in the comments of channels-transcode.sh and it says:

# You can run without comparing with the transcode database and use current directory thus:
#  channels-transcoder.sh 62 63 DEST_DIR="" DAYS=0 TMPDIR="$(pwd)"

What are the 62 and 63 command line options? Are they the show numbers to tanscode?
Thanks!
-Andrew

I had the same issues and could never get it to work. I gave up, but I might try to get it to work on my Synology one day.

@amann180 and @timstephens24: It certainly seems to be a real issue. I followed some hunches and might have tracked down the problem and fixed it (bearing in mind I can’t reproduce it).

This fix, in part, necessitates the addition of the coreutils prerequisite, which is typically installed by default in Linux distributions, but not on Macs. I know for a fact that this is available via the Mac homebrew software manager (brew install coreutils), but can’t say for sure about other package managers. Once that is installed, you should also go into your ~/.profile and remove any lines starting alias realpath.

I have updated both the install.sh script and the channels-transcoder.sh script, as well as edited the README file for some additional clarity. My solution is actually more simple now.

@amann180: Running channels-transcoder.sh with specific numbers allows transcoding of show by number, yes. It will transcode regardless of whether it already exists in transcode.db.

Here’s an alternative I’ve used on macOS in the past:

myrealpath() { /usr/bin/ruby -e 'puts File.realpath(ARGV[0])' -- "$@" }

Nice. However, coreutils on home brew does the job perfectly.

Reviving an old thread here–I’d love to get this working, but so far I am stuck on the install. I’ve already run

brew install jq curl coreutils atomicparsley parallel

And everything is installed, but when I run the installer, it tells me that pre-requisites are not installed, and it stops. Any ideas?

Some pre-requisites not installed.
Please try again or use “bash install.sh force” to proceed regardless, then edit your prefs file manually
You will need wget regardless for this install script to work

I tried the script but ended up giving up. I didn’t want to risk a perfectly clean installation of the Channels server. At some point in time, developer @tmm1 mentioned the possibility of putting some post-processing into the server code. I’m crossing my fingers on that. Even the most basic post processing (transcode, copy, move) selected on a per-file o per-series base would be a killer function for many. Maybe @tmm1 can tell us if that’s still in the roadmap…

A quick comment that the script does not in any way change the Channels DVR install or its directories. Sorry you’re having problems with it. Hopefully I’ll have a chance to make it more user friendly in the near future.

I am coming from a mythtv backend and Kodi front end on a Mac mini and I leveraged some scripts to create something very similar.

I took the code from github and made some modifications and potential bug fixes. It was a great starting/ending point for me.

The key thing that I changed was to encode in x265 HEVC that supports iTunes. This HEVC format runs on my macOS. iOS and tvOS. I will probably parameterize it so that the default is x264 and you can turn on x265 vs the current hardcore to x264. X265 takes more encoding time but it is smaller at the same quality.

I focused on just transcoding my TV passes that I have explicitly called out . For example. “Poldark” vs all recordings in the last day. I tend to record sports and just want to time shift slightly. I created a batch file with the list of Tv shows that I kickoff at midnight.

Btw . I looked at the install script and install the prerequisites and code manually. That helped me know where things resided.

New feature request for Channels DVR: I think I saw this alreaady but I would love to have in the recording to have the ability of calling out user jobs ( like this script) to post process the recording and hsve the ability of deferring that job to a time like midnight. This capability is what I had with mythiv. You can commercial trim , encode or whatever.

Excellent. Thanks! This was intended more as a seed for community contributions, and so I fully encourage this sort of modification and contribution. If you can modify it without breaking the existing functionality, that would be really handy to upload or fork from the existing code.

Great work here!!!

Any way to isolate one show to transcode? As in I only want “Dr Phil” to transcode daily. Not all of my recordings.

I use a modified fork version, but you should be able to do

channels-transcoder.sh “Dr Phil" or is it “Dr. Phil”

in fact, I have a script that is nothing more than a batch file that just lists them individually and I run it every night. (midnight)

If the recording was already transcode…it will see that a previous recording is already there and stop.

Batch file running at midnight…

channels-transcoder.sh “Sherlock"
channels-transcoder.sh “Grey’s"

channels-transcoder.sh “60 Minutes"

Here is the actual statement.

/usr/local/bin/channels-transcoder.sh “Designated” CLEAR_DB=1 VERBOSE=1

2 Likes

Yeah, I'm having the same issues. Installed all the prerequisites but still getting the warning about some needing to be installed.

Tried the 'force' install and that seemed to get further but then appeared to fail in that any channels-transcoder.sh commands are not found.

Any help would be greatly appreciated @karlmitchell

thanks

I was able to get this working with my Mac-mini. I was trying to reduce the processing strain and I substituted the the encoding library, libx264, for , h264_videotoolbox. I thought the library, h264_videotoolbox, is the hardware encoding library. I noticed that processor usage was about 30-40 reduced, but the quality suffered significantly as well. Bit rate dropped from 4,128 kb/s with libx264 to 788 kb/s h264_videotoolbox. Is there away to make the hardware encoding better. Here are my command line options to FFmpeg.

libx264

ffmpeg -hide_banner -i 10217.mpg -i 10217.ffmeta -map_metadata 1 -map 0:0 -c:v libx264 -preset veryfast -crf 21 -profile:v high -level 4.0 -map 0:1 -c:a:0 aac -b:a:0 160k -map 0:2 -c:a:1 copy -movflags faststart 10217.mp4

h264_videotoolbox

ffmpeg" -hide_banner -i 10217.mpg -i 10217.ffmeta -map_metadata 1 -map 0:0 -c:v h264_videotoolbox -preset veryfast -crf 21 -profile:v high -level 4.0 -map 0:1 -c:a:0 aac -b:a:0 160k -map 0:2 -c:a:1 copy -movflags faststart 10217.mp4

You need -b:v 4000k

1 Like

Anyone get this to work with HW yet? I tried editing the code, but was unsuccessful as I don't fully understand.

Option hwaccel (use HW accelerated decoding) cannot be applied to output url h264_cuvid -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.

Error parsing options for output file h264_cuvid.

Error opening output files: Invalid argument






Option profile:v (set profile) cannot be applied to input url 243.ffmeta -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.

Error parsing options for input file 243.ffmeta.

Error opening input files: Invalid argument```

The position of the arguments to ffmpeg is important. In this case you must add the hardware related options after -i

This the code looks like -i comes before the FFMPEG variables?

-hwaccel -c:v h264_cuvid is not correct.

hwaccel takes a value and you're not providing one. And I think you probably want to use h264_nvenc instead.