Page 1 of 1

Poor Man's HandbrakeCLI Queuing

PostPosted: Fri Nov 18, 2011 6:23 am
by tc60045a
Because this approach isn't 100% finished, it goes in "Support" and not in "Recipes" -- Mr. Noodle, I will rely upon you to move it over at such time when you deem necessary.

I've come up with an approach for queuing batched HandbrakeCLI processes, which could only be done with the help of Hazel's persistence in trying to apply rules repeatedly to items. I've posted it in the Handbrake forum as it could help others who aren't on Macs, and would hope to contain discussions here on this approach to the idiosyncrasies of using Hazel for implementing this approach.

Please take a look and comment here or there with your feedback. I hope when it is done that other Hazel users like myself will finally have a solution that plays nice with CPUs. And I hope it helps Noodlesoft sell a bunch more licenses for Hazel!!

https://forum.handbrake.fr/viewtopic.php?f=10&t=22633

Best,

TC

Re: Poor Man's HandbrakeCLI Queuing

PostPosted: Fri Nov 18, 2011 1:37 pm
by Mr_Noodle
I'm sure I'm probably missing something here but can't you just have Hazel monitor a folder and process each file as it appears one at a time? As long as you don't run Handbrake in the background, it won't process the next file until the current one is finished.

Re: Poor Man's HandbrakeCLI Queuing

PostPosted: Thu Dec 01, 2011 6:51 pm
by dhy8386
I can't remember now but i thought i had trouble controlling the number of instances of CLI that would launch if say 4 files were put into a folder to be encoded. It may be related to the fact that I am using automator scripts created by a user over at Macforums to managed my workflow. Nonetheless, what I did was write a simple Applescript to control how many instances of HCLI could run at once. But since the automator scripts also utilize makemkv for processing blu ray rips, what I REALLY wanted was control over how many CLI processes could run at once (both HCLI and Makemkv). Enclosing it here in case its helpful. Note the reference to the color labels of the file is because thats how the script knows which ones to process since I use colors throughout the workflow for better manageability.

Code: Select all
try
   set processcountMKV to do shell script "/bin/ps -acx | grep -c makemkvcon"
on error
   set processcountMKV to 0
end try

try
   set processcountMM to do shell script "/bin/ps -acx | grep -c mkvmerge"
on error
   set processcountMM to 0
end try

try
   set processcountME to do shell script "/bin/ps -acx | grep -c mkvextract"
on error
   set processcountME to 0
end try

try
   set processcountH to do shell script "/bin/ps -acx | grep -c HandBrakeCLI"
on error
   set processcountH to 0
end try

try
   set origFilepath to quoted form of POSIX path of (theFile as alias)
   set shellCommand to "automator -i " & origFilepath & " '/Users/dhy/Library/Services/Batch Rip • Batch Encode (Finder)(TV).workflow' ;"
   
   delay 5
   
   tell application "Finder"
      if label index of theFile = 6 then
         error number -128
      else if processcountMKV + processcountME + processcountMM + processcountH ≥ "2" then
         error number -128
      else
         do shell script shellCommand
      end if
   end tell
end try