[SOLVED] Macro stops after running the first script

When I run the script with Terminal, everything works as expected.
When I try it with KM, after it converts the 1st video, it stops and it shows this error:
image

Summary

2023-06-20 22:11:04 Execute macro “Create Promo Videos (available via Raycast)” from trigger Do Script
2023-06-20 22:12:18 Action 13891760 failed: Execute a Shell Script failed with script error: ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
built with clang version 11.1.0
configuration: --prefix=/opt/anaconda3 --cc=x86_64-apple-darwin13.4.0-clang --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame --pkg-config=/Users/runner/miniforge3/conda-bld/ffmpeg_1627813741069/_build_env/bin/pkg-config
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, image2, from '/Users/dannywyatt/My Files/Music Projects/Danny Wyatt/Music/365 Challenge - Music/Songs/_Assets Promo Videos/Facebook Story.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 50047 kb/s
Stream #0:0: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 1080x1920, 25 fps, 25 tbr, 25 tbn, 25 tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from '/Users/dannywyatt/My Files/Music Projects/Danny Wyatt/Music/365 Challenge - Music/Songs/_Assets Promo Videos/_audio.wav':
Metadata:
encoded_by : Logic Pro X
date : 2023-05-24
creation_time : 17:00:49
time_reference : 164713500
umid : 0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C9007076
coding_history :
Duration: 00:01:46.30, bitrate: 1411 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[swscaler @ 0x7f90b8bd2000] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x7f90b9808200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7f90b9808200] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x7f90b9808200] 264 - core 161 r3030M 8bd6d28 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - x264, the best H.264/AVC encoder - VideoLAN - options: cabac=1 ref=3 deblock=1:-3:-3 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=2.00:0.70 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-4 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.20
Output #0, mp4, to '/Users/dannywyatt/My Files/Music Projects/Danny Wyatt/Music/365 Challenge - Music/Songs/_Assets Promo Videos/Exported Videos/New test video - Facebook Story.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1080x1920, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s
Metadata:
encoder : Lavc58.91.100 aac
frame= 2709 fps= 43 q=-1.0 Lsize= 4267kB time=00:01:48.24 bitrate= 323.0kbits/s speed=1.73x
video:1673kB audio:2505kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.130039%
[libx264 @ 0x7f90b9808200] frame I:11 Avg QP: 7.07 size:136942
[libx264 @ 0x7f90b9808200] frame P:682 Avg QP: 6.30 size: 92
[libx264 @ 0x7f90b9808200] frame B:2016 Avg QP: 9.67 size: 71
[libx264 @ 0x7f90b9808200] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 @ 0x7f90b9808200] mb I I16..4: 78.6% 13.8% 7.7%
[libx264 @ 0x7f90b9808200] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:100.0%
[libx264 @ 0x7f90b9808200] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0% L0:50.1% L1:49.9% BI: 0.0%
[libx264 @ 0x7f90b9808200] 8x8 transform intra:13.8% inter:15.2%
[libx264 @ 0x7f90b9808200] coded y,uvDC,uvAC intra: 12.7% 11.3% 11.2% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7f90b9808200] i16 v,h,dc,p: 95% 4% 1% 0%
[libx264 @ 0x7f90b9808200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 24% 20% 4% 5% 5% 5% 5% 6%
[libx264 @ 0x7f90b9808200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 20% 12% 6% 8% 9% 8% 6% 6%
[libx264 @ 0x7f90b9808200] i8c dc,h,v,p: 96% 2% 2% 1%
[libx264 @ 0x7f90b9808200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7f90b9808200] ref P L0: 96.7% 0.5% 2.8%
[libx264 @ 0x7f90b9808200] ref B L0: 35.5% 64.5%
[libx264 @ 0x7f90b9808200] ref B L1: 99.1% 0.9%
[libx264 @ 0x7f90b9808200] kb/s:126.41
[aac @ 0x7f90b7814a00] Qavg: 295.516
text-script: line 1: ffmpeg: command not found
2023-06-20 22:12:18 Execute a Shell Script failed with script error: ffmpeg version 4.3.2 Copyright (c) 2000-2021 the FFmpeg developers
built with clang version 11.1.0
configuration: --prefix=/opt/anaconda3 --cc=x86_64-apple-darwin13.4.0-clang --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame --pkg-config=/Users/runner/miniforge3/conda-bld/ffmpeg_1627813741069/_build_env/bin/pkg-config
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, image2, from '/Users/dannywyatt/My Files/Music Projects/Danny Wyatt/Music/365 Challenge - Music/Songs/_Assets Promo Videos/Facebook Story.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 50047 kb/s
Stream #0:0: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 1080x1920, 25 fps, 25 tbr, 25 tbn, 25 tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from '/Users/dannywyatt/My Files/Music Projects/Danny Wyatt/Music/365 Challenge - Music/Songs/_Assets Promo Videos/_audio.wav':
Metadata:
encoded_by : Logic Pro X
date : 2023-05-24
creation_time : 17:00:49
time_reference : 164713500
umid : 0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C9007076
coding_history :
Duration: 00:01:46.30, bitrate: 1411 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[swscaler @ 0x7f90b8bd2000] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x7f90b9808200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7f90b9808200] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x7f90b9808200] 264 - core 161 r3030M 8bd6d28 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - x264, the best H.264/AVC encoder - VideoLAN - options: cabac=1 ref=3 deblock=1:-3:-3 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=2.00:0.70 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-4 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.20
Output #0, mp4, to '/Users/dannywyatt/My Files/Music Projects/Danny Wyatt/Music/365 Challenge - Music/Songs/_Assets Promo Videos/Exported Videos/New test video - Facebook Story.mp4':
Metadata:
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1080x1920, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Metadata:
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s
Metadata:
encoder : Lavc58.91.100 aac
frame= 2709 fps= 43 q=-1.0 Lsize= 4267kB time=00:01:48.24 bitrate= 323.0kbits/s speed=1.73x
video:1673kB audio:2505kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.130039%
[libx264 @ 0x7f90b9808200] frame I:11 Avg QP: 7.07 size:136942
[libx264 @ 0x7f90b9808200] frame P:682 Avg QP: 6.30 size: 92
[libx264 @ 0x7f90b9808200] frame B:2016 Avg QP: 9.67 size: 71
[libx264 @ 0x7f90b9808200] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 @ 0x7f90b9808200] mb I I16..4: 78.6% 13.8% 7.7%
[libx264 @ 0x7f90b9808200] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:100.0%
[libx264 @ 0x7f90b9808200] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0% L0:50.1% L1:49.9% BI: 0.0%
[libx264 @ 0x7f90b9808200] 8x8 transform intra:13.8% inter:15.2%
[libx264 @ 0x7f90b9808200] coded y,uvDC,uvAC intra: 12.7% 11.3% 11.2% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7f90b9808200] i16 v,h,dc,p: 95% 4% 1% 0%
[libx264 @ 0x7f90b9808200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 24% 20% 4% 5% 5% 5% 5% 6%
[libx264 @ 0x7f90b9808200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 20% 12% 6% 8% 9% 8% 6% 6%
[libx264 @ 0x7f90b9808200] i8c dc,h,v,p: 96% 2% 2% 1%
[libx264 @ 0x7f90b9808200] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7f90b9808200] ref P L0: 96.7% 0.5% 2.8%
[libx264 @ 0x7f90b9808200] ref B L0: 35.5% 64.5%
[libx264 @ 0x7f90b9808200] ref B L1: 99.1% 0.9%
[libx264 @ 0x7f90b9808200] kb/s:126.41
[aac @ 0x7f90b7814a00] Qavg: 295.516
text-script: line 1: ffmpeg: command not found. Macro “Create Promo Videos (available via Raycast)” cancelled (while executing Execute Shell Script).

Create Promo Videos (available via Raycast).kmmacros (9.4 KB)

Summary

Keyboard Maestro Export

As I'm not comfortable with shell scripting, does it have anything to do with me using && to run multiple tasks one after the other? If so, what should I use instead?
As I mentioned, when using the same script with Terminal, everything works. This issue is only with KM.

You almost got there.

Looking at the log, you can see that first ffmpeg runs and spews out a lot of stuff, but then at the end we see:

ffmpeg: command not found.

And you can see in your script:

image

That you are running the command /opt/anaconda3/bin/ffmpeg initially, which is working, but then running the command ffmpeg which is not being found (because the PATH is not set to include it, see Path in Shell Scripts).

The additional commands executed after the && need also to have their location fully specified as /opt/anaconda3/bin/ffmpeg.

1 Like

But of course!!! Makes perfect sense. It's the small details that make the difference. I totally missed that...
It's working now. Thank you so much, Peter! :slight_smile:

1 Like