Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

HandBrakeCLI Automation Script (Transcoding Server)

Featured Replies

  • Author

In the meantime, run

 

ts -K

 

This will kill the queue.

  • Replies 72
  • Views 32.1k
  • Created
  • Last Reply
  • Author

Posting 096 now, corrected the last path issue in cron (cron jobs don't see /usr/local/bin in the path).

Thank you GJones - will let you know how it performs tonight!

Worked like a charm last night!  Thanks for the quick fix.

Spoke too soon... got home this evening to find it up to monkey business again.  It has properly encoded the files that needed encoding, except one.  When I ran ts, I saw processes numbered 15,434 and down!!!

 

I've just run "tcrepack" from the terminal, and it's picked up the missing one and is encoding now.  Although somewhat strangely when I look at the output of ts, it shows the job twice... one finished immediately, and the other is running now.  Maybe this is just a peculiarity of ts which I never noticed before.

 

I'll see whether it stops there, or starts adding thousands of processes.  Assuming it doesn't, any ideas what else could be going wrong with the cron job?

 

----EDIT----

Even running tcrepack manually now sets off the infinite loop.  The encode failed midway through, and off it ran... caught it while it was still in the 100s!

 

:(

  • Author

Please post the contents of the /tmp/ts-out...... files where it finished immediately. It will help me determine the cause.

Please post the contents of the /tmp/ts-out...... files where it finished immediately. It will help me determine the cause.

 

There are thousands of the files, but they contain one of two types of content:

 

1) ts-out.1NZ44J (as an example, but always the same)

/usr/local/bin/tcremkv: line 34: [: !=: unary operator expecte
unknown option (-C)
****************************************
*  Comparing File Sizes                *
****************************************
du: cannot access '/mnt/user/TV/Alias/Season_2/Alias_H264.S02E15.mkv':  No such file or directory
du: cannot access '/mnt/user/replaced/Alias.S02E15.mkv': No such file or directory
****************************************
*  ck                                  *
****************************************

BEFORE

AFTER

 

2)  ts-out.1c01Lj (other files contain two consecutive numbers)

70
71

 

Please let me know if you need something else.  Thank you!

  • Author

Please post the contents of the /tmp/ts-out...... files where it finished immediately. It will help me determine the cause.

 

There are thousands of the files, but they contain one of two types of content:

 

1) ts-out.1NZ44J (as an example, but always the same)

/usr/local/bin/tcremkv: line 34: [: !=: unary operator expecte
unknown option (-C)
****************************************
*  Comparing File Sizes                *
****************************************
du: cannot access '/mnt/user/TV/Alias/Season_2/Alias_H264.S02E15.mkv':  No such file or directory
du: cannot access '/mnt/user/replaced/Alias.S02E15.mkv': No such file or directory
****************************************
*  ck                                  *
****************************************

BEFORE

AFTER

 

2)  ts-out.1c01Lj (other files contain two consecutive numbers)

70
71

 

Please let me know if you need something else.  Thank you!

  • I am testing the fix to avoid the race condition that reruns tcrepack or tcrepackblu.  It stores the last run time for each and exits if it was less than 5 minutes ago.
  • Please run tclanglist against the file it is failing to transcode. Then run tclang on it as well.  Please post the results.  This is an attempt to determine why the script dislikes your input file.

 

  • Author

Version 0961 Posted

 

A new check avoids infinite loops by making sure that tcrepack and tcrepackblu aren't called rapidly.  A new variable (MINBTWN) in tcOPTIONS controls the wait, which defaults to 300 seconds (5 minutes).

 

If it runs more quickly than that, it exits with a message to avoid trying to transcode the same failing file forever.

Please run tclanglist against the file it is failing to transcode. Then run tclang on it as well.  Please post the results.  This is an attempt to determine why the script dislikes your input file.

 

Ran both, and there were no results.  The command I ran was:

tclanglist /mnt/user/TV/Alias/Season_2/Alias_H264.S02E15.mkv

and

tclang /mnt/user/TV/Alias/Season_2/Alias_H264.S02E15.mkv

 

Is that the correct syntax?

 

Why isn't the file being skipped given the _H264 extension?

  • Author

Do you by chance have overlap between your HD and SD search directories in tcOPTIONS?

I'll check tonight, but almost certain I've got the HD search path # out (don't have many HD movies)... although maybe that could cause an issue perhaps?

Figured out the problem... it was a bad mkv file.  I guess that TS was trying to encode, failing and then because it wasn't able to encode, trying again, and again, and again.

 

Haven't given this too much thought, but not sure what your thoughts are about building something in to rename the file to say "Episode - S01E01_BAD.mkv", or perhaps even moving out into /mnt/replaced/bad.  I'm not sure how reliable the script would be at detecting a bad file, but currently theres no indication, and a bad file would not be noticed.

 

At least now I understand the odd behavior!

  • Author

There are reasons to avoid renaming a failed file.  One would be that the file will be completed at a later time.  I may, however, write out a file to that folder pointing out that the file cannot be encoded at this time.

 

Let me consider it.  Renaming the file would be clean but I want to determine if there is another way.  I do not want to rename every file in someone's collection just because they are using some strange encoding, etc.  The "skip" file would allow a timestamp in there as well to keep tcre... from attempting to process it for a set period of time.

Understand and agree... certainly don't want to go rushing in and changing things without considering the consequences for sure.

 

Is there any way for HandBrake to pass back an error if it can't be encoded?  Because if HandBrake can't encode the file, then I can't really think of any way that this fact would change given time.  If it's strangely encoded, then (unless there's a change in the MKV specification), it will still be unencodable in the future too. 

 

Not that it's a big deal, but such files would just keep getting put into the TS queue every night unnecessarily.

 

I do like the idea of some kind of log file though.

  • Author

There is a log of every tcremkv and tcremkvblu job created by ts under /tmp.  I had considered moving those files under the _transcode directory periodically, renamed according to the source file.  The log you refer to would more than likely be based on the actions of tcrepack and tcrepackblu (still considering combining the two).  This second log would be high-level, listing the actions of the two repack programs along with the end result of individual tcremkv and tcremkvblu tasks.  It would also show files flagged as issues report on positive results as well.

 

To do this, I would need to rework the current method for picking candidates in tcrepack and tcrepackblu.  I would need to check each for a skip file in their directory prior to them being counted.  This would be more user friendly in that a user that never logged in via telnet or ssh could fix their file and then remove the skip file from the directory.

  • Author

I changed the name of the thread in the hope that it would make it more obvious what the package actually accomplishes.

Agree with the above, and understand it would be quite a coding change.

 

One small thing I've been meaning to say is that it would be great to move the regular expression search string to tcOPTIONS for each.  I've customized mine to reflect my specific naming conventions, so would be useful to move it into tcOPTIONS (perhaps into an "Advanced" section, as it's not as simple as the directories, XMBC IP address etc.) so that when there are updates to the main scripts, it doesn't overwrite my little customization.

 

Hope the new title brings this on the radar for more people... it's a great little tool you've developed GJones.  Takes a little bit of work to implement, but once it's in and running you can just leave it to schedule and sort encoding, which otherwise is a very

tedious and labor intensive task!

  • Author

I am in the process of moving the search includes/excludes to tcOPTIONS.  It is a balancing act to keep that somewhat maintainable and yet, efficient.  That should be something up for testing next week.  At that point, I will likely turn to get the options built into unmenu controls.

Hi GJones... your favorite TC user here again...  ;)

 

1) Was having some more issues today for some reason... after some lengthy troubleshooting, I found that HandBrake was throwing an error with one of the arguments in the CLI options.  It seems the "-C 3" isn't being recognized... I deleted that from the tcOPTIONS file and it's working tickety-boo again.  From reading the online HandBrake CLI guidance, it seems to be something to do with the number of CPUs, which it will attempt to auto-detect anyway.

 

2) Just noticed the following entry in the syslog:

Tower shfs: shfs_setxattr: setxattr: /mnt/cache/TV/Alias/Season_2/Alias.S02E02_H264.mkv (95) Operation not supported

Anything to worry about?

3) ClunkClunk has been kind enough to distribute a SVN trunk release of HandBrake (see here) - this release fixes the previous issues re: HD audio, so (I believe) it can pass-through original HD audio.  Do you know how you would amend the CLI options in tcOPTIONS so that HD sources are encoded with pass-through audio?

  • Author

You will be fine without -C. I use it because I have four cores and only want to use three.

 

I am looking at HD audio but my hardware does not support it. Updates coming soon for that.

Great to hear... my amp doesn't support it either, but like keeping it there in case one day I get to upgrade to a system that does!

 

Anything to be concerned about re: the syslog entry?

  • Author

The syslog entry pertains to file permissions. No great concern.

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.