FFWorks
I often need to deliver mp4's for client using FFworks...
Would be fantastic to automate the process.
Would look something like...
Launch FFworks
Add video file...
Set the Target to Mp4
Set the set to video to passthrough
Add external audio file...
Set the set to audio to AAC
Set the set to audio bitrate to 320
Start encoding...
FFWorks is a front end for FFmpeg, so this could possibly be done via terminal to?
https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg
*Replacing audio stream
If your input video already contains audio, and you want to replace it, you need to tell ffmpeg which audio stream to take:
ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4
The -map option makes ffmpeg only use the first video stream from the first input and the first audio stream from the second input for the output file.
*
- Christian Scheuer @chrscheuer2021-11-27 10:30:40.549Z
Hi Stephen,
You can run any terminal command in SoundFlow by using sf.system.exec, for example like so:
var inputPath = ""; var outputPath = ""; sf.system.exec({ commandLine: `ffmpeg -i "${inputPath}" -i audio.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 "${outputPath}"`, });
Christian Scheuer @chrscheuer2021-11-27 10:31:06.354Z
Your inputPath for example could come from the first selected file in Finder:
var inputPath = sf.ui.finder.firstSelectedPath;
Christian Scheuer @chrscheuer2021-11-27 10:31:32.742Z
You can also consider using the brilliant Replace Audio in Video File app from Jesper Ankarfeldt :) @JesperA
Christian Scheuer @chrscheuer2021-11-27 10:36:00.747Z
- SStephen Webster @Stephen_Webster
No need to reinvent the wheel, i missed that app, but that should work
Christian Scheuer @chrscheuer2021-11-27 10:54:08.952Z
Very true :) I think there's a lot of people using Jesper's app, but of course there's less room to configure your own settings, so if you're decently comfortable with ffmpeg you could probably make some really nice workflows with a direct integration.
If you haven't already seen it, the reverse app (ingestion) is also available, ie. converting videos into a format that PT likes (Video Converter for Pro Tools):
https://soundflow.org/store/video-converter-for-pro-tools
- In reply tochrscheuer⬆:
Christian Scheuer @chrscheuer2021-11-27 10:35:33.278Z
Obviously I missed the wave input file here, but you can imagine it's easy to add :)
- SStephen Webster @Stephen_Webster
Some useful scripts here to...
https://brendandawes.com/blog/handy-ffmpeg-automator-scripts
- In reply tochrscheuer⬆:
Mitch Willard @Mitch_Willard
hi @chrscheuer,
We are having some strange behaviour with this code working successfully.
The odd thing is, on our Intel Macs, this works perfectly, on our Silicon Macs it won't execute the command line.
however if I log the command line and paste it into terminal, it works perfectly. So the command is correct for what we need.
Is there something I'm missing that we need to do in order for it to correctly work on a Silicon Mac?
here is the sample of the code.
const commandLine = `ffmpeg -i "${input}" -c:v dnxhd -b:v 185M -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" -r 25 -c:a aac -b:a 192k"${output}"` sf.system.exec({ commandLine })
Cheers
Mitch
Christian Scheuer @chrscheuer2024-12-09 16:15:06.062Z
Hi Mitch,
This is likely because the shell's $PATH doesn't properly include the directories in which the symlinks for the ffmpeg executable for your platform resides. It would depend a bit on how you install ffmpeg.
If you use homebrew, ffmpeg is installed in different places on Silicon and Intel Macs. On Intel, it'll be in a location like
/usr/local/Cellar/ffmpeg/{version}/bin/ffmpeg
whereas on Silicon, it'll be in something like/opt/homebrew/Cellar/ffmpeg/{version}/bin/ffmpeg
.Note that for homebrew on Intel, I think it installs symlinks in
/usr/local/bin
which it may not do on Silicon.You'd get better results by specifying the full path to the ffmpeg executable in your command line, and possibly distribute the binary yourselves if you're working within a team.
Mitch Willard @Mitch_Willard
Thanks for this @chrscheuer. That makes a lot of sense!
And that is now working!! thanks so much! you're the best!
More on this though, is there a way that Soundlfow can tell if you're on a Intel Mac or a Silicon Mac?
That way I can write the code to use the appropriate $PATH depending on which computer it is on seeing all our Macs use our common package on the Soundflow Business account.
Mitch Willard @Mitch_Willard
all good @chrscheuer,
@Nico_Aparicio already found me the answer.
function macType() { const code = sf.system.exec({ commandLine: `uname -m` }).result const type = code === 'arm64' ? 'Silicon' : 'Intel' return type }