2

I use Automator together with ffmpeg which works great. A shell script command is run with two parameters:

  • -ss 00:00:00 (starting)
  • -t 00:00:00 (time length)

Q: Is it possible to set the two parameters using a popup window?

enter image description here

1

You asked "Is it possible to set the two parameters using a popup window?" and the answer to that is yes.

Here is one example of how it could be done:

In between the Ask for Finder Items action and the Run Shell Script action add a Run AppleScript action with the following AppleScript code:

on run {input, parameters}
    display dialog "Enter the start time and length:" default answer "-ss 00:00:00 -t 00:00:00" buttons {"Cancel", "OK"} ¬
        with title "Set FFMPEG Start Time and Length: -ss 00:00:00 -t 00:00:00"
    set beginning of input to text returned of result
    return input
end run

Then in the Run Shell Script action, change the script to the following code:

start_time_and_length="$1"
shift

for f in "$@"
do
    /usr/local/Cellar/ffmpeg/3.2.4/bin/ffmpeg -i "$f" $start_time_and_length -c:v copy -c:a copy -f mp4 "${f%.*}.mp4"
done

Automator Workflow


How this works:

  • The Ask for Finder Items action passes a list of filesystem objects to the next action.

  • The Run AppleScript action uses a display dialog to add the start time and length to the beginning of the list passed to it from the Ask of Finder Items action.

  • The Run Shell Script action receives what was returned from the Run AppleScript action, in this case the value of return input as a list in which its first item is the text returned from the result of the display dialog, being the start time and length. This gets set to the start_time_and_length variable and then shift is used to remove it from the list that gets passed to for f in "$@" to process the remaining items in the list.


Note: If you have a issue using the AppleScript code, shown above, then you could use the following as a workaround:

on run {input, parameters}
    set tempList to {}
    display dialog "Enter the start time and length:" default answer "-ss 00:00:00 -t 00:00:00" buttons {"Cancel", "OK"} ¬
        with title "Set FFMPEG Start Time and Length: -ss 00:00:00 -t 00:00:00"
    set end of tempList to text returned of result
    repeat with i from 1 to (count of input)
        set end of tempList to item i of input
    end repeat
    copy tempList to input
    return input
end run
1
  • Both AppleScript works perfectly. I try to solve the two values with two separate input window, but it is still perfect. Thank you for your time! – Chili Sep 6 '17 at 7:14

You must log in to answer this question.

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