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?
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"
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"
Related
I want to convert and resize a video and put a logo on it. I am doing this with 2 different command line like this.
Command 1:
D:\Logo\ffmpeg -i "D:\Logo\video.mxf" -vf scale=1280:720 "D:\Logo\video.mxf_fullHDtoHD.mp4"
Command 2:
D:\Logo\ffmpeg -i "D:\Logo\video.mxf_fullHDtoHD.mp4" -i D:\Logo\logo_720p.png -filter_complex "[0:v][1:v] overlay=60:50" "D:\Logo\output_720p_with_logo.mp4"
Can I do this in just one command?
Combined command:
ffmpeg -i "D:\Logo\video.mxf" -i D:\Logo\logo_720p.png -filter_complex "[0:v]scale=1280:720[bg];[bg][1:v]overlay=60:50" "D:\Logo\output_720p_with_logo.mp4"
I want to combine two ffmpeg commands to single ffmpeg command.
exec("ffmpeg -i mimic/api/video/1560754087943.mp4 -i logo.png -filter_complex"." overlay=20:20"." topleft.mp4");
exec('ffmpeg -i topleft.mp4 -vf drawtext="fontfile=ARIBLK.ttf: text=sonukh3921: fontcolor=white: fontsize=20: x=20: y=65" output_video.mp4');
Is this possible to use the output from the first command for the second line, without using two separate commands?
The below single command is just for you:
ffmpeg \
-i mimic/api/video/1560754087943.mp4 \
-i logo.png \
-filter_complex "overlay=20:20[video];[video]drawtext=fontfile=ARIBLK.ttf:text=sonukh3921:fontcolor=white:fontsize=20:x=20:y=65" \
output_video.mp4
I wanted to run a PSNR check on a encoded segment but avoid extracting the segment in a lossless codec first for comparsion. I just wanted to trim the input, however it looks like this is disabled.
My command:
ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[0v][1v]psnr" -f null -
This will run through the whole original input file and not trim the video in the filter.
If I try to trim the input with -ss and -t, only the input -ss flag is working. It will set the input correct but ignore the -t timestamp.
ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4 -filter_complex [0:v][1:v]psnr -f null -
Different placement of the -t will have no effect.
I also tried to set the duration in trim while keeping the -ss input which is working.
ffmpeg -ss 10 -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=duration=10,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[0v][1v]psnr" -f null -
I did try this with end and end_frame but neither one worked.
The same applies if I use -lavfi instead of -filter_complex.
I did have a brief look at the sourcecode of the PSNR filter but could not find any refrences to trim or -t.
Is this function blocked or am I doing something wrong?
Would there be an alternative way to doing this without encoding a lossless version of the same segment to compare?
The original command is almost fine. However, the order of inputs should be swapped, and if there's any audio, that should be disabled.
ffmpeg -i original.mp4 -i segment.mp4 -filter_complex "[0:v]trim=10:20,setpts=PTS-STARTPTS[0v];[1:v]setpts=PTS-STARTPTS[1v];[1v][0v]psnr" -an -f null -
Also, in the snippet below
ffmpeg -ss 10 -i original.mp4 -t 10 -i segment.mp4
if you meant to limit the duration of original.mp4, then -t 10 should be placed before -i original.mp4.
I am merging two .webm files using ffmpeg application(3.3.3) as follows,
ffmpeg -i input1.webm -c copy temp1.webm
ffmpeg -i input2.webm -c copy temp2.webm
ffmpeg -i temp1.webm -i temp2.webm -filter_complex [0:v]scale=640:360,setsar=1[l];[1:v]scale=640:360,setsar=1[r];[l][r]hstack;[0][1]amix" -vsync 0 -ac 2 -deadline realtime -cpu-used 8 output.webm
Above works fine for me but I want to do this in one step/ command. I am launching the ffmpeg.exe from my C++ application on windows so I have to do it for three times. I see that using | or && doesn't work for me. If I try from command prompt then it works using &&.
Please suggest.
I'm having issues escaping ':' symbol and displaying localtime in a hms(HH:MM:SS) format for overlay over a Live input(MPEG-TS) which is then pushed out as Live output - I've fumbled my way to displaying 'localtime' in a format which achieves about half of what I'm trying to get to, the code sample of that is:
ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H %M %S}'" -f LIVE_OUTPUT
What it achieves is that it displays local time in a "HH MM SS" format instead of "HH:MM:SS"...
I did try escaping ':' by writing it like this:
ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H\\:%M\\:%S}'" -f LIVE_OUTPUT
and this:
ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H\:%M\:%S}'" -f LIVE_OUTPUT
as well as like this:
ffmpeg -re -hide_banner -i LIVE_INPUT -vf drawtext="fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%H \: %M \: %S}'" -f LIVE_OUTPUT
But none of the above helped as it returns different errors because ffmpeg tries to either parse '%H' '%M' and '%S' as multiple, separate arguments for localtime (localtime then complains that it can only accept x1 argument at most), or ffmpeg complains that there are loose '%' characters near "H" ... clearly I'm not escaping it correctly or my argument order is incorrect...
Your original requirement of displaying HH:MM:SS can be achieved as follows
ffmpeg -re -hide_banner -i LIVE_INPUT \
-vf drawtext="fontsize=90:fontcolor=white: \
fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\:%X}'" \
-f LIVE_OUTPUT
I have worked for days and finally solved this problem, it turns out the solution is simple, just add more \ until you finally got it.
ffmpeg -re -hide_banner -i LIVE_INPUT -vf "drawtext=fontsize=90:fontcolor=white:fontfile=/Windows/Fonts/arial.ttf:text='%{localtime\\:%H\\\\\:%M\\\\\:%S}'" -f LIVE_OUTPUT