This PowerShell script automates audio file conversion using FFmpeg and provides functionalities for managing output locations and overwriting existing files.
Features:
- Converts audio files to a specified format using FFmpeg.
- Creates a subfolder named
audioconversion_timestamp
in the directory containing the input audio file(s). - Converts each input audio file within the newly created subfolder.
- Allows customization of audio parameters (sampling rate, channels, bitrate, codec) through the
Execute-FFmpeg
function (assumed to be defined in the same folder) - Provides the option to overwrite existing output files using the
-Overwrite
parameter in theExecute-FFmpeg
function (default:$false
).
Requirements:
- PowerShell
- FFmpeg (installed and accessible on the system)
How to Use:
-
Save the script as
Run-AudioConversion2.ps1
,Execute-FFmpeg.ps1
andRun-AudioConversion2.cmd
. -
Modify the
Execute-FFmpeg
function (in a separate file) to define the desired audio conversion parameters and FFmpeg command structure. -
Open a PowerShell window and navigate to the directory containing the script.
-
Run the script, specifying the paths to your audio files as arguments:
.\Run-AudioConversion2.ps1 "C:\path\to\audio1.mp3" "C:\path\to\audio2.wav" "C:\path\to\audio3.flac"
Notes:
- This script assumes the
Execute-FFmpeg
function is defined in the same folder. - Modify the
Execute-FFmpeg
function to match your specific audio conversion needs and FFmpeg command structure. - The script will overwrite existing output files by default. Use the
-Overwrite:$false
parameter in theRun-AudioConversion2.ps1
script to prevent overwriting.
Default FFMPEG Configuration:
The Execute-FFmpeg
function has the following default settings:
- Audio Rate: 8000 Hz
- Audio Channels: 1 (Mono)
- Audio Bitrate: 8 kbps
- Audio Codec: "pcm_mulaw"
This configuration is suitable for low-bandwidth, telephony-related audio conversions. You can adjust these settings by passing different values for AudioRate
, AudioChannels
, AudioBitrate
, and AudioCodec
to the Execute-FFmpeg
function.
Additional Considerations:
- Implement error handling for more robust operation.
- Consider adding features like user input for audio parameters or allowing users to select the output folder.