No internet connection
  1. Home
  2. How to

FFWorks

By Stephen Webster @Stephen_Webster
    2021-11-27 09:00:55.346Z

    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.
    *

    • 12 replies
    1. 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}"`,
      });
      
      1. Your inputPath for example could come from the first selected file in Finder:

        var inputPath = sf.ui.finder.firstSelectedPath;
        
        1. You can also consider using the brilliant Replace Audio in Video File app from Jesper Ankarfeldt :) @JesperA

            1. SStephen Webster @Stephen_Webster
                2021-11-27 10:36:33.794Z

                No need to reinvent the wheel, i missed that app, but that should work

                1. 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

          1. In reply tochrscheuer:

            Obviously I missed the wave input file here, but you can imagine it's easy to add :)

          2. In reply tochrscheuer:
            Mitch Willard @Mitch_Willard
              2024-12-07 03:10:23.127Z

              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

              1. 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.

                1. Mitch Willard @Mitch_Willard
                    2024-12-09 22:57:50.880Z

                    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.

                    1. Mitch Willard @Mitch_Willard
                        2024-12-09 23:43:04.916Z

                        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
                        }