HandBrakeCLI Script

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Re: HandBrakeCLI Script Tue Nov 19, 2013 10:51 am • by FreddieShoreditch
The only thing I can think of is that HandBrake might not be in the location or there is an error in the directories. Everything else seems to look fine to me.
FreddieShoreditch
 
Posts: 9
Joined: Thu May 16, 2013 2:55 pm

Re: HandBrakeCLI Script Tue Nov 19, 2013 5:13 pm • by Plex
Thanks for the response, FreddyShoreditch. I'll triple check everything tonight, but am certain HandBrakeCLI is in the location identified (/usr/local/bin) and the paths of the directories are correct (I dragged the folder to the terminal and copied the location from there). Very strange...

For the converting_directory and the output_directory, do I want to end the path with a "/", as I've done in the post above, or just put the quotes after the Process or Output folder?

I read in another post something about smart quotes and how they could cause problems. Looking below, it looks like some of the quotes are indeed smart and are going in the wrong direction in a few places, but that might have to do with the forum and when I used the color coding.

As an aside: what does the red and green color coding mean? Does that indicate some sort of syntax error?

Thanks again.
Plex
 
Posts: 14
Joined: Mon Nov 18, 2013 8:02 pm
Location: Colorado

Re: HandBrakeCLI Script Tue Nov 19, 2013 9:54 pm • by Plex
Confirmed: everything is in the right place and the directories are correct. Any ideas?
Plex
 
Posts: 14
Joined: Mon Nov 18, 2013 8:02 pm
Location: Colorado

Re: HandBrakeCLI Script Wed Nov 20, 2013 1:24 am • by Plex
Here's my debug log, if that helps:

Marker - Nov 19, 2013, 10:22:45 PM
2013-11-19 22:23:15.366 hazelworker[1001] DEBUG: Unexpected type for Mail download URL: (null)
2013-11-19 22:23:15.368 hazelworker[1001] DEBUG: Could not scan past browser.download.dir preference
2013-11-19 22:23:15.772 hazelworker[1001] Processing folder Process (forced)
2013-11-19 22:23:15.772 hazelworker[1001] DEBUG: Initialized
2013-11-19 22:23:15.772 hazelworker[1001] DEBUG: Pausing to wait for things to settle down.
2013-11-19 22:23:17.864 hazelworker[1001] DEBUG: Processing directories: (
"/Volumes/HTPC/Media/Movies/AVCHD/Process"
)
2013-11-19 22:23:17.865 hazelworker[1001] DEBUG: About to process directory /Volumes/HTPC/Media/Movies/AVCHD/Process
2013-11-19 22:23:17.869 hazelworker[1001] DEBUG: Received file event: {
date = "2013-11-20 05:23:15 +0000";
path = "<ComNoodlesoft_NoodlePathSet: 0x7fe6bae2dd80> - (\n \"/Volumes/HTPC/Media/Movies/AVCHD/Process\"\n)";
}
2013-11-19 22:23:17.870 hazelworker[1001] DEBUG: .DS_Store: File is hidden/invisible. Skipping.
2013-11-19 22:23:17.872 hazelworker[1001] 20131117183149.MTS: Rule Sony NEX-5R to Handbrake CLI matched.
2013-11-19 22:23:17.872 hazelworker[1001] DEBUG: Manual run. Forcing actions to be executed.
2013-11-19 22:23:18.193 hazelworker[1001] DEBUG: == script output ==
/var/folders/q8/zyf0cjw97jxbd6wnlp42c19h0000gn/T/hazelworker-1001/hazelscript.sh: line 5: syntax error near unexpected token `('
/var/folders/q8/zyf0cjw97jxbd6wnlp42c19h0000gn/T/hazelworker-1001/hazelscript.sh: line 5: `converting_filenameHD=“$converting_directory$filename (HD).m4v”'

== End script output ==
2013-11-19 22:23:18.196 hazelworker[1001] [Error] Shell script failed: Error processing shell script on file /Volumes/HTPC/Media/Movies/AVCHD/Process/20131117183149.MTS.
2013-11-19 22:23:18.196 hazelworker[1001] Shellscript exited with non-successful status code: 2
2013-11-19 22:23:18.196 hazelworker[1001] DEBUG: Tapping error retry sequence
2013-11-19 22:23:18.197 hazelworker[1001] 20131117184830.MTS: Rule Sony NEX-5R to Handbrake CLI matched.
2013-11-19 22:23:18.198 hazelworker[1001] DEBUG: Manual run. Forcing actions to be executed.
Plex
 
Posts: 14
Joined: Mon Nov 18, 2013 8:02 pm
Location: Colorado

Re: HandBrakeCLI Script Wed Nov 20, 2013 9:44 am • by FreddieShoreditch
I haven't tried this myself - I grew very fed up with the problems of trying to do this long before I succeeded in having a working, fully automated system complete.

Maybe try::

converting_filenameHD="$converting_directory" & "$filename" & " (HD).m4v"
FreddieShoreditch
 
Posts: 9
Joined: Thu May 16, 2013 2:55 pm

Re: HandBrakeCLI Script Wed Nov 20, 2013 10:44 am • by Plex
So you've never gotten this to work? That's not encouraging...

I tried the suggestion above and now get a whole new suite of errors in the debug log:

Marker - Nov 20, 2013, 7:42:27 AM
2013-11-20 07:42:34.171 hazelworker[1414] DEBUG: Unexpected type for Mail download URL: (null)
2013-11-20 07:42:34.234 hazelworker[1414] DEBUG: Could not scan past browser.download.dir preference
2013-11-20 07:42:34.814 hazelworker[1414] Processing folder Process (forced)
2013-11-20 07:42:34.814 hazelworker[1414] DEBUG: Initialized
2013-11-20 07:42:34.814 hazelworker[1414] DEBUG: Pausing to wait for things to settle down.
2013-11-20 07:42:36.908 hazelworker[1414] DEBUG: Processing directories: (
"/Volumes/HTPC/Media/Movies/AVCHD/Process"
)
2013-11-20 07:42:37.124 hazelworker[1414] DEBUG: About to process directory /Volumes/HTPC/Media/Movies/AVCHD/Process
2013-11-20 07:42:37.128 hazelworker[1414] DEBUG: Received file event: {
date = "2013-11-20 14:42:33 +0000";
path = "<ComNoodlesoft_NoodlePathSet: 0x7faaf3d46d60> - (\n \"/Volumes/HTPC/Media/Movies/AVCHD/Process\"\n)";
}
2013-11-20 07:42:37.130 hazelworker[1414] DEBUG: .DS_Store: File is hidden/invisible. Skipping.
2013-11-20 07:42:37.163 hazelworker[1414] 20131117183149.MTS: Rule Sony NEX-5R to Handbrake CLI matched.
2013-11-20 07:42:37.163 hazelworker[1414] DEBUG: New rule signature. Executing actions.
Old signature: {ANY displayExtensions ==[cd] "MTS"}:{(shellscript:/bin/bash:cd7b8145f9d74b9bbdb2112d90cf5043,{
})}
New Signature:{ANY displayExtensions ==[cd] "MTS"}:{(shellscript:/bin/bash:ef85f3e9228b533691cf446efdc1ff1f,{
})}
2013-11-20 07:42:37.652 hazelworker[1414] DEBUG: == script output ==
/var/folders/q8/zyf0cjw97jxbd6wnlp42c19h0000gn/T/hazelworker-1414/hazelscript.sh: line 5: syntax error near unexpected token `HD'
/var/folders/q8/zyf0cjw97jxbd6wnlp42c19h0000gn/T/hazelworker-1414/hazelscript.sh: line 5: `converting_filenameHD=“$converting_directory” & “$filename” & “(HD).m4v”'

== End script output ==
2013-11-20 07:42:37.756 hazelworker[1414] [Error] Shell script failed: Error processing shell script on file /Volumes/HTPC/Media/Movies/AVCHD/Process/20131117183149.MTS.
2013-11-20 07:42:37.756 hazelworker[1414] Shellscript exited with non-successful status code: 2
2013-11-20 07:42:37.756 hazelworker[1414] DEBUG: Tapping error retry sequence
2013-11-20 07:42:37.758 hazelworker[1414] 20131117184830.MTS: Rule Sony NEX-5R to Handbrake CLI matched.
2013-11-20 07:42:37.758 hazelworker[1414] DEBUG: New rule signature. Executing actions.
Old signature: {ANY displayExtensions ==[cd] "MTS"}:{(shellscript:/bin/bash:cd7b8145f9d74b9bbdb2112d90cf5043,{
})}
New Signature:{ANY displayExtensions ==[cd] "MTS"}:{(shellscript:/bin/bash:ef85f3e9228b533691cf446efdc1ff1f,{
})}
2013-11-20 07:42:38.105 hazelworker[1414] DEBUG: == script output ==
/var/folders/q8/zyf0cjw97jxbd6wnlp42c19h0000gn/T/hazelworker-1414/hazelscript.sh: line 5: syntax error near unexpected token `HD'
/var/folders/q8/zyf0cjw97jxbd6wnlp42c19h0000gn/T/hazelworker-1414/hazelscript.sh: line 5: `converting_filenameHD=“$converting_directory” & “$filename” & “(HD).m4v”'

== End script output ==
2013-11-20 07:42:38.105 hazelworker[1414] [Error] Shell script failed: Error processing shell script on file /Volumes/HTPC/Media/Movies/AVCHD/Process/20131117184830.MTS.
2013-11-20 07:42:38.105 hazelworker[1414] Shellscript exited with non-successful status code: 2
2013-11-20 07:42:38.106 hazelworker[1414] DEBUG: Tapping error retry sequence
2013-11-20 07:42:38.106 hazelworker[1414] DEBUG: Writing out DB file: /Volumes/HTPC/Media/Movies/AVCHD/Process
Plex
 
Posts: 14
Joined: Mon Nov 18, 2013 8:02 pm
Location: Colorado

Re: HandBrakeCLI Script Wed Nov 20, 2013 12:46 pm • by Mr_Noodle
Try updating to the latest version released this morning and go back into the script and re-type any double-quotes. There was a bug where Mavericks would enable smart quotes.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: HandBrakeCLI Script Wed Nov 20, 2013 1:03 pm • by Plex
[Looks like the board was hacked... bummer. I digress...]

Now we're in business! It's working!
I'm only confused on why, with the following code, the output destination is the same as the Process folder:

Code: Select all
filename=$(basename "$1")
filename=${filename%.*}
converting_directory="/Volumes/HTPC/Media/Movies/AVCHD/Process/"
output_directory="/Volumes/HTPC/Media/Movies/AVCHD/Output/"
converting_filenameHD="$converting_directory$filename (HD).m4v"

/usr/local/bin/HandBrakeCLI -i "$1" -o "$converting_filenameHD" -f mp4 -4 --decomb -w 1920 -l 1080 --loose-anamorphic --modulus 2 -e x264 -q 20 -r 30 --pfr -a 1 -E faac -6 dpl2 -R Auto -B 160  -D 0 --gain 0 --audio-fallback ffac3 --x264-profile=high --h264-level=4.0
Plex
 
Posts: 14
Joined: Mon Nov 18, 2013 8:02 pm
Location: Colorado

Re: HandBrakeCLI Script Fri Nov 22, 2013 12:11 am • by Plex
Here's what I got to work. I think the terminology was confusing me.

I removed the output directory line in the code from the post above above (since it wasn't actually mapping to anything) and changed the converting directory to my desired output location, since Hazel has already established the input directory. Right?

Code: Select all
filename=$(basename "$1")
filename=${filename%.*}
converting_directory="/Volumes/HTPC/Media/Movies/AVCHD/Output/"
converting_filenameHD="$converting_directory$filename (HD).m4v"

/usr/local/bin/HandBrakeCLI -i "$1" -o "$converting_filenameHD" -f mp4 -4 --decomb -w 1920 -l 1080 --loose-anamorphic --modulus 2 -e x264 -q 20 -r 30 --pfr -a 1 -E faac -6 dpl2 -R Auto -B 160  -D 0 --gain 0 --audio-fallback ffac3 --x264-profile=high --h264-level=4.0


Now, if only I could get the output to match the creation and modification dates of the input! :D
Plex
 
Posts: 14
Joined: Mon Nov 18, 2013 8:02 pm
Location: Colorado

Previous

Return to Support