AppleScript Help Needed

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
mcdirt
Posts: 7
Joined: Sun Feb 06, 2011 9:31 am

AppleScript Help Needed

Post by mcdirt »

Hi,

I have setup an AppleScript to convert EYETV files to smaller versions using HandbrakeCLI. I'm having a problem with 1 part - I cannot send the commands to handbrake properly. What I want to send to handbrake is ...

HandBrakeCLI -i inputfile -o outputfile --preset="AppleTV"


The code I am using is ...

set inputFile to currentFileName
set outputFile to text item 1 of currentFileName & ".mp4"

set shellCommand to "HandBrakeCLI -i " & inputFile & " -o " & outputFile & " --preset=" & quoted form of "AppleTV"
do shell script shellCommand



I have tried using "\ and quoted form of but still not getting it right, looking at the Events window, I'm not getting the right info being sent to HandBrake.
HandBrakeCLI & the input file are in the same folder.

Any help appreciated.
rgds mcdirt
Chris_BBR
Novice
Posts: 63
Joined: Tue Nov 24, 2009 2:36 pm

Re: AppleScript Help Needed

Post by Chris_BBR »

What exactly are the error messages you're seeing from (a) HandBrakeCLI and (b) AppleScript?

Cheers, Chris
Last edited by Chris_BBR on Thu Feb 10, 2011 2:12 pm, edited 1 time in total.
mcdirt
Posts: 7
Joined: Sun Feb 06, 2011 9:31 am

Re: AppleScript Help Needed

Post by mcdirt »

Hi Chris,

Nothing from HandBrakeCLI that I can see, error from AppleScript is

do shell script "HandBrakeCLI -i '60 Minutes.eyetv' -o '60 Minutes.mp4' --preset='AppleTV'"
--> error number -1708
«event ascrgdut»
--> error number -1708
do shell script "HandBrakeCLI -i '60 Minutes.eyetv' -o '60 Minutes.mp4' --preset='AppleTV'"
--> error number -10004
Chris_BBR
Novice
Posts: 63
Joined: Tue Nov 24, 2009 2:36 pm

Re: AppleScript Help Needed

Post by Chris_BBR »

Does "HandBrakeCLI -i '60 Minutes.eyetv' -o '60 Minutes.mp4' --preset='AppleTV'" work if you run it directly from the command line?

Cheers, Chris
Deleted User 11865

Re: AppleScript Help Needed

Post by Deleted User 11865 »

mcdirt wrote:HandBrakeCLI & the input file are in the same folder.
And is that folder in your PATH? Try specifying the full path to HandBrakeCLI.
Chris_BBR
Novice
Posts: 63
Joined: Tue Nov 24, 2009 2:36 pm

Re: AppleScript Help Needed

Post by Chris_BBR »

Rodeo wrote:And is that folder in your PATH? Try specifying the full path to HandBrakeCLI.
That was going to be my next question! Step by step... :D

Cheers, Chris
mcdirt
Posts: 7
Joined: Sun Feb 06, 2011 9:31 am

Re: AppleScript Help Needed

Post by mcdirt »

EYETV files, HandBrake & script all in same folder. At airport waiting for flight - will try Handbrake directly tomorrow, thanks.

rgds mcdirt
Chris_BBR
Novice
Posts: 63
Joined: Tue Nov 24, 2009 2:36 pm

Re: AppleScript Help Needed

Post by Chris_BBR »

mcdirt wrote:EYETV files, HandBrake & script all in same folder.
But that's not the folder that AppleScript itself runs from, and therefore calls 'do shell script' from.

As a result, you'll have to either add your working folder to PATH as Rodeo suggests, or pass the full POSIX '/path/to/HandBrakeCLI' to 'do shell script', before AppleScript can find HandBrakeCLI.

Either way, you'll also need to cite the full POSIX paths to your input and output files for all activity to take place in your working folder.

Get the process working with a sample encode from the command line first, and then patch that back into your script and progressively drop in your variables until you're where you need to be.

Cheers, Chris
mcdirt
Posts: 7
Joined: Sun Feb 06, 2011 9:31 am

Re: AppleScript Help Needed

Post by mcdirt »

Very helpful, many thanks - I'll try all that soon as I can.
Thanks again.

rgds mcdirt
mcdirt
Posts: 7
Joined: Sun Feb 06, 2011 9:31 am

Re: AppleScript Help Needed

Post by mcdirt »

I checked my previous code and that had all the path names etc in it - moving everything into the one folder was an attempt to try and simplify things. I think the problem is with my commands to Handbrake - in Terminal, if I type in ...

/Applications/HandBrakeCLI -i "/users/mcdirt/documents/eyetv archive/60 Minutes.eyetv" -o "/users/mcdirt/documents/eyetv archive/60 Minutes.mp4" --preset="AppleTV"


then I get this text message from Handbrake ...

[10:35:20] hb_init: checking cpu count
[10:35:20] hb_init: starting libhb thread
HandBrake 0.9.5 (2011010300) - Darwin x86_64 - http://handbrake.fr
2 CPUs detected
Opening /users/mcdirt/documents/eyetv archive/60 Minutes.eyetv...
[10:35:20] hb_scan: path=/users/mcdirt/documents/eyetv archive/60 Minutes.eyetv, title_index=1
libbluray/bdnav/index_parse.c:157: indx_parse(): error opening /users/mcdirt/documents/eyetv archive/60 Minutes.eyetv/BDMV/index.bdmv
libbluray/bluray.c:960: nav_get_title_list(/users/mcdirt/documents/eyetv archive/60 Minutes.eyetv) failed (0x10182aa00)
[10:35:20] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 4.1.3
libdvdread: Encrypted DVD support unavailable.
libdvdread: Couldn't find device name.
libdvdnav:DVDOpenFilePath:findDVDFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdnav:DVDOpenFilePath:findDVDFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[10:35:20] dvd: not a dvd - trying as a stream/file instead
[10:35:20] hb_stream_open: open /users/mcdirt/documents/eyetv archive/60 Minutes.eyetv/000000001233a8f1.eyetvp failed
[10:35:20] libhb: scan thread found 0 valid title(s)
No title found.
HandBrake has exited.


Can anyone tell from this what is wrong?
Thankb

rgds mcdirt
Chris_BBR
Novice
Posts: 63
Joined: Tue Nov 24, 2009 2:36 pm

Re: AppleScript Help Needed

Post by Chris_BBR »

Try pointing HandBrakeCLI directly at the actual recording file (.mpg, .mp4, etc.) that lives inside the .eyetv package.

If that doesn't work, export the recording from EyeTV as 'MPEG Program Stream' (this should just dump out the raw recording immediately rather than take time doing any transcoding) and point HB at that.

Also, what type of EyeTV recording is this -- analogue SD, digital SD, HD etc (show 'Details' in the 'Save As' dialog above)?

Cheers, Chris
moseisleydk
Posts: 1
Joined: Sun Feb 13, 2011 12:22 pm

Re: AppleScript Help Needed

Post by moseisleydk »

Check out http://www.mos-eisley.dk/MCE/Apple%20Me ... rt.sh.aspx

PS: Currently I am working on various improvements like better quality (High-Profile preset is not good) and forced subtitles..
Deleted User 11865

Re: AppleScript Help Needed

Post by Deleted User 11865 »

moseisleydk wrote:(High-Profile preset is not good)
http://www.mos-eisley.dk/MCE/Apple%20Media%20Center/eyetvexport.sh.aspx wrote:

Code: Select all

/Applications/HandBrakeCLI […] --preset High Profile > eyetvexport.log
You're not using it. There's no preset called "High" and the defaults are FFmpeg MPEG-4 Visual at 1000 Kbps, single pass; no wonder it looks bad.

Code: Select all

--preset="High Profile"
Also, only progress is written to stdout. All useful logging info is written to stderr; you might want to redirect that instead.
mcdirt
Posts: 7
Joined: Sun Feb 06, 2011 9:31 am

Re: AppleScript Help Needed

Post by mcdirt »

Finally found something that works - needs the "--main-feature" at the end, thanks for all help - here's the code that works ...

--Start the conversion
set shellCommand to " /Applications/HandBrakeCLI --preset=" & quoted form of "AppleTV" & " -i " & quoted form of inputFile & " -o " & quoted form of outputFile & " --main-feature"
set results to do shell script shellCommand


rgds mcdirt
Deleted User 11865

Re: AppleScript Help Needed

Post by Deleted User 11865 »

Glad you got it to work :-)
Chris_BBR
Novice
Posts: 63
Joined: Tue Nov 24, 2009 2:36 pm

Re: AppleScript Help Needed

Post by Chris_BBR »

Well done -- good to know for the future.

Cheers, Chris
Eponymous
Posts: 2
Joined: Sun May 01, 2011 1:04 pm

Re: AppleScript Help Needed

Post by Eponymous »

mcdirt,

Can you post your script somewhere? This is exactly what I'm trying to do. Thanks.
Post Reply