0

I have this ffmpeg command that I would like to send to terminal through appelscript. It works when I run it directly in terminal.

ffmpeg -i score.mov -i palette.png -filter_complex \
"fps=8,scale=600:-1:flags=lanczos[x];[x][1:v]paletteuse" -f image2pipe -vcodec ppm - | convert -delay 15 -loop 0 -layers Optimize - output39.gif

This doesn't compile in scripteditor.

tell application "Terminal"
    do script "ffmpeg -i score.mov -i palette.png -filter_complex \
"fps=8,scale=600:-1:flags=lanczos[x];[x][1:v]paletteuse" -f image2pipe -vcodec ppm - | convert -delay 15 -loop 0 -layers Optimize - output39.gif"
end tell

I get "Expected end of line but found identifier"

Anyone have an idea what to do?

2 Answers 2

2

Use do shell script – as suggested in the other answer – , delete the line separators and replace the double quotes in the string with single quotes.

do shell script "ffmpeg -i score.mov -i palette.png -filter_complex 'fps=8,scale=600:-1:flags=lanczos[x];[x][1:v]paletteuse' -f image2pipe -vcodec ppm - | convert -delay 15 -loop 0 -layers Optimize - output39.gif"
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Worked perfect :) I Just had to add the full path /usr/local/bin/ to ffmpeg and convert to make it run properly.
1

You're close but have some definite syntax issues.

You don't have to tell Terminal, first of all.

The proper syntax in AppleScript for shell commands is: "do shell script" followed by the command. Remember you are sending text to this function, so properly escape out the " and ' and $ and what not in your script with double \\'s as to not confuse the script.

For future consistency sake, I like to set all shell applications I utilize to properties at the beginning of my app:

property grep : do shell script "which grep"

...then recall them in my script lines, but that isn't necessary.

Try this:

do shell script "ffmpeg -i score.mov -i palette.png -filter_complex \
\\"fps=8,scale=600:-1:flags=lanczos[x];[x][1:v]paletteuse\\" -f image2pipe \
-vcodec ppm - | convert -delay 15 -loop 0 -layers Optimize - output39.gif"

1 Comment

Thank you very much Eric! But now I get the same error on this part: -f image2pipe instead Any ideas? I suck at this. But I want to learn :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.