FFmpeg
FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, remux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation.
Contents
Audio Editing Scripts
The instructions and scripts have been written in and tested on the Windows operating system.
AAC Fades
Unfortunately, the AAC format cannot have fades applied to it in a lossless way. Therefore, when applying a fade-in or a fade-out to AAC files the audio will be lossy transcoded. Luckily, lossy transcoding AAC files is far less destructive than other lossy formats such as MP3s. However, it is still highly recommended to only apply fades to an AAC file that has been cut out of the main AAC file, which can then be merged back with the main AAC file once the fades have been applied. This will minimise the lossy transcoding and keep it to the fade-in and fade-out sections.
Use-case Scenario
- Complete all edits of your AAC file in MP3DirectCut and leave it in there.
- Fade-in:
- Cut out the fade-in section: start of file for d seconds. For example: if you want the fade-in to be 5 seconds long, then cut out the first 5 seconds. It doesn't have to be exactly 5 seconds, but must not be less otherwise the sound might "jump up" when merged back into the main file.
- Process this to-be-faded-in.aac file using the fade-in script below.
- Open the resulting faded-in.aac file using another MP3DirectCut instance, select all the audio, copy and paste into the start of the main/original AAC file that is still open in MP3DirectCut. Thus, you've now replaced the original starting audio with the new faded-in audio.
- Process this to-be-faded-in.aac file using the fade-in script below.
- Cut out the fade-in section: start of file for d seconds. For example: if you want the fade-in to be 5 seconds long, then cut out the first 5 seconds. It doesn't have to be exactly 5 seconds, but must not be less otherwise the sound might "jump up" when merged back into the main file.
- Fade-out:
- Cut out the fade-out section: end of file for d seconds. For example: if you want the fade-out to be 7 seconds long, then cut out the last 7 seconds. It doesn't have to be exactly 7 seconds, but is best to not be less otherwise the sound doesn't completely fade-out to nothing.
- Process this to-be-faded-out.aac file using the fade-out script below.
- Open the resulting faded-out.aac file using another MP3DirectCut instance, select all the audio, copy and paste into the end of the main/original AAC file that is still open in MP3DirectCut. Thus, you've now replaced the original ending audio with the new faded-out audio.
- Process this to-be-faded-out.aac file using the fade-out script below.
- Cut out the fade-out section: end of file for d seconds. For example: if you want the fade-out to be 7 seconds long, then cut out the last 7 seconds. It doesn't have to be exactly 7 seconds, but is best to not be less otherwise the sound doesn't completely fade-out to nothing.
- Fade-in:
Making these small cuts, processing the fades, then copying & pasting back in, is the best way to minimise negatively impacting the majority of the audio with lossy transcoding.
To note: both scripts will output aac files with a 320kbps bitrate. This can be changed if necessary by altering the -b:a number.
AAC Fade-In
Copy and paste the below text into a text file and rename it aac-fade-in.cmd
:: Name: aac-fade-in.cmd :: Purpose: Configures ffmpeg to amend the volume to a fade-in - **LOSSY** :: Usage: drag and drop aac file onto this script :: Author: jaybeee @ themixingbowl.org :: Revision: Feb 2021 - v0.1 @ECHO OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION :: variables begin with v :: set name of this script without file extension SET vMe=%~n0 :: set name of the parent directory where this script resides SET vParent=%~dp0 :: set ffmpeg path location if not already in WINDOWS PATH ** CHANGE ME ** ::SET vffmpeg="C:\PATH\TO\FFMPEG.EXE" :: Ask the user to enter the duration of the fade-in in seconds echo ** Enter duration of fade-in in ss.mmm format when prompted ** SET /p vSss="Fade-in duration (ss.mmm): " :: call ffmpeg to fade in the first d seconds starting at ss :: we then have to lossy transcode the audio MKDIR aac FOR %%f IN (%*) DO ffmpeg -i %%f -af afade=t=in:ss=0:d=%vSss% -b:a 320k "aac\%%~nf.aac" :: Finish ECHO Finished aac fade-in :: pause can be used to view the extraction details PAUSE :END ENDLOCAL ECHO ON @EXIT /B 0
AAC Fade-Out
Copy and paste the below text into a text file and rename it aac-fade-out.cmd
:: Name: aac-fade-out.cmd :: Purpose: Configures ffmpeg to amend the volume to a fade-out - **LOSSY** :: Usage: drag and drop aac file onto this script :: Author: jaybeee @ themixingbowl.org :: Revision: Feb 2021 - v0.1 @ECHO OFF SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION :: variables begin with v :: set name of this script without file extension SET vMe=%~n0 :: set name of the parent directory where this script resides SET vParent=%~dp0 :: set ffmpeg path location if not already in WINDOWS PATH ** CHANGE ME ** ::SET vffmpeg="C:\PATH\TO\FFMPEG.EXE" :: Ask the user to enter the duration of the fade-in in seconds echo ** Enter duration of fade-in in ss.mmm format when prompted ** SET /p vEss="Fade-out duration Time (ss.mmm): " :: call ffmpeg to fade-out the first d seconds starting at ss :: we then have to lossy transcode the audio MKDIR aac FOR %%f IN (%*) DO ffmpeg -i %%f -af afade=t=out:st=0:d=%vEss% -b:a 320k "aac\%%~nf.aac" :: Finish ECHO Finished aac fade-out :: pause can be used to view the extraction details PAUSE :END ENDLOCAL ECHO ON @EXIT /B 0