Need help on creating a macros for replacing audio in video with Shutter Encoder
I want to create a macros that allows me to select 2 files on finder, an audio file along with a video file, and with the press of a button have these 2 files open up in Shutter Encoder, select the following function: "REPLACE AUDIO" and finalizing the process by clicking on the "START FUNCTION" button.
Here's what I have so far: I can open up Shutter Encoder and it will take me to the Browse window where I could select the 2 files but I cannot find a way to find the 2 files if these were previously selected in Finder (before executing the macros).
Can anyone tell me how to accomplish this?
Here's my script so far:
sf.app.launch({
path: "/Applications/Shutter Encoder.app",
});
sf.wait({
intervalMs: 4000,
});
sf.ui.app("net.java.openjdk.java").mainWindow.buttons.whoseDescription.is("Browse...").first.elementClick();
sf.ui.app("net.java.openjdk.java").windows.whoseTitle.is("Import items").first.splitGroups.first.scrollAreas.first.children.whoseRole.is("AXOutline").whoseDescription.is("sidebar").first.children.whoseRole.is("AXRow").allItems[1].children.whoseRole.is("AXCell").first.getElement("AXTitleUIElement").elementClick();
- Christian Scheuer @chrscheuer2024-08-05 09:51:58.645Z
Hi Oscar,
Have you checked out Jesper Ankarfeldt's "Replace Audio in Video File" app in SoundFlow?
Might be a possible replacement.- OOscar Vargas @Oscar_Vargas
Thanks so much for quick response Christian. The only video I could find about this app on the store is 4 years old, if it hasn't changed much I think I could have a better quicker workflow if I succeed in finding a way to make it work through Shutter Encoder.
Any leads or suggestions on how I might be able to select video file and audio in Finder and have Shutter look for them through the Browse function inside the app?Christian Scheuer @chrscheuer2024-08-05 16:51:35.389Z
I don't have Shutter Encoder myself and I'm currently busy with SF 5.9 (and other stuff). But in terms of navigating to a specific file path, there's a bunch of open source code on the forum and the store to do this. Search for navigateToInDialog and you should get some code.
To get the path of the selected file in Finder:
var path = sf.ui.finder.firstSelectedPath;
.Christian Scheuer @chrscheuer2024-08-05 16:52:44.805Z
You could also look into automating ffmpeg directly. You'd use
sf.system.exec
to run ffmpeg directly from your command line. It's a bit tricky to get all parameters to be correct, but in a case of just replacing the audio in a video file, the syntax should be relatively easy.If you can write a command line in Terminal to do it, SF can automate running that for you.
Christian Scheuer @chrscheuer2024-08-05 16:54:55.484Z
As an example:
const sourceVideoFilePath = '/path/to/source/video.mp4'; const sourceAudioFilePath = '/path/to/source/audio.mp3'; const targetVideoFilePath = '/path/to/target/video_with_new_audio.mp4'; const command = `ffmpeg -i "${sourceVideoFilePath}" -i "${sourceAudioFilePath}" -c:v copy -map 0:v:0 -map 1:a:0 -shortest "${targetVideoFilePath}"`; sf.system.exec({ commandLine: command, });
Depending on how you install ffmpeg, you might have to specify the full path to the ffmpeg executable. Once you've got ffmpeg installed, from Terminal you can write the following to get the full path to the ffmpeg executable:
which ffmpeg