1

I have written an apple script previously to automate a task I do in my work many times.

With Apple updating to Catalina I will lose the use of Quicktime 7 (which is part of my Image sequencing workflow) I want to take the opportunity rewrite my script.

I'm taking it one step at a time and the first is running FFmpeg.

I have written a script:

ffmpeg -r 25 -f image2 -pattern_type glob -i '*.JPG' -codec:v prores_ks -profile:v 0 imagemagick_TL_Test_01.mov

This works in Terminal if I navigate to the folder and run it. Great.

I now want to find a way to make the action drag and droppable.

I have tried to adapt my old code to include this at the relevant section to run the ffpmeg on the dropped folder but I have encountered error after error. Ideally renaming the output file to have the grandparent folder name and save in the parent folder.

on open dd

    repeat with d in dd
        set d to d's contents
        tell application "Finder"
            set seq1 to (d's file 1 as alias)
            set dparent to d's container as alias
            set mov to "" & dparent & (dparent's name) & ".mov"
        end tell
        do shell script "d=" & d's POSIX path's quoted form & "
    /opt/local/bin/ffmpeg -r 25 -f image2 -i \"" & seq1 & "\" '*.JPG' -codec:v prores_ks -profile:v 0 \"" & dparent & ".mov\" && exit
    "
    end repeat
end open

This gives me the error :

[image2 @ 0x7ff9cd000000] Could find no file with path '***:Users:***:Desktop:imagemagick_TL_Test:01:_DAN7741.JPG' and index in the range 0-4
***:Users:***:Desktop:imagemagick_TL_Test:01:_DAN7741.JPG: No such file or directory

Any pointers would be greatly appreciated! Thank you!

1

An important consideration when programming is to come up with a plan for debugging your code. Here is how I would have coded the code for debugging.

It's difficult to debug an on open handler. I add an on run handler where I can dummie up the input to a common routine that is called by on run and on open. fyi: I corrected how the input was processed from on open.

(* 
   AskDifferent question:
     https://apple.stackexchange.com/questions/366992/running-ffmpeg-in-automator-applescript
 Use log statements.

 It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.

For testing, run in the Script Editor.
    1) Click on the Event Log tab to see the output from the log statement
    2) Click on Run

 *)
on run
    --  debug lines
    set desktopPath to (path to desktop) as string

    -- here is a log statment.
    log "desktopPath = " & desktopPath

    -- Be sure to select a file on your DESKTOP.
    set see to alias (desktopPath & "auto-show-2015.mp4")

    -- Simulate dropped items list.
    set dropped_items to {see}

    common(dropped_items)

end run


-- Gets invoked here when something is dropped on this AppleScript icon

on open dropped_items

    common(dropped_items)

end open



on common(dd)

    repeat with d in dd
        set d to d's contents
        log d
        tell application "Finder"
            --set seq1 to (d's file 1 as alias)  -- dropped items come in as an array of aliased items. 
            set seq1 to d
            set dparent to d's container as alias
            set mov to "" & dparent & (dparent's name) & ".mov"
            log "mov is " & mov
        end tell

        set toUnix to "d=" & d's POSIX path's quoted form & " /opt/local/bin/ffmpeg -r 25 -f image2 -i \"" & seq1 & "\" '*.JPG' -codec:v prores_ks -profile:v 0 \"" & dparent & ".mov\" && exit
    "
        log "toUnix is " & toUnix
        set fromUnix to do shell script toUnix
        log "fromUnix is " & fromUnix
    end repeat
end common
  • Hi @historystamp, thanks for your response. I' really not a coder, but I've tried to follow your guide and have come across lots of problems. I'm juts trying to adapt the code I had along with the ffmpeg code but I simply can't get it to run. The ffmpeg code works within Terminal when I cd to the folder and run the script but I can't get it to work as an app. – cursor_major Aug 19 at 17:26
  • I've copied your code in to Script Editor and altered the *.mp4 to be a file I have on my Desktop. Does this just test or confirm that the name grabbing function of the script works? Would I delete this bit of the code once I have figured out the rest? Looking at the events section at the bottom of Script Editor when I run the code I basically get the same error message : – cursor_major Aug 19 at 17:33
  • '[image2 @ 0x7fe9fa803a00] Could find no file with path ':Users::Desktop:DLTV_Portfolio_Rollover 1-6Mbps.mov' and index in the range 0-4 :Users::Desktop:DLTV_Portfolio_Rollover 1-6Mbps.mov: No such file or directory" number 1' – cursor_major Aug 19 at 17:33
  • Perhaps I'm trying to do too many things at once. Would you be able to advise how I might just run the ffmpeg script in an app written in script editor? It doesn't matter about the renaming or save location, I'll try and get to that later. – cursor_major Aug 19 at 17:36
  • Please post the current version of your script. For a test, rename all files and folders that you use only contain characters a-zA-Z0-9 are in the names. – historystamp Aug 19 at 19:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .