I want to convert mp3 files to mp3 but with my settings. Could someone help me to create python code or a command for cmd to perform such action with ffmpeg? I have hundreds of mp3 files so I need to automate it. Settings are in below picture.
I tried myself to configure it, but I had problems with finding in ffmpeg docs information about bit rate mode
and quality
settings.
import subprocess
def convert_mp3(input_filepath:str, output_filepath:str):
#FFmpeg command to convert the input MP3 file
ffmpeg_cmd = [
'ffmpeg',
'-i', input_filepath,
'-ar', '48000', # Set the sample rate to 48000Hz
'-b:a', '320k', # Set the audio bitrate to 320kbps
'-vn', # Disable video stream
'-codec:a', 'libmp3lame', # Use LAME MP3 codec
'-f', 'mp3', # Specify the output file format as MP3
output_filepath
]
subprocess.run(ffmpeg_cmd, check=True)
Insure that 'ffmpeg' is a recognized command by adding the path of your ffmpeg/bin folder to your environment variables.