Summary
- Get mp3 from mp4
- Convert wav to mp3
Get mp3 from video mp4 or avi etc.
ffmpeg -i sample.avi -q:a 0 -map a sample.mp3
How to make it with python
import os from tkinter import filedialog filename = filedialog.askopenfilename() command = f"ffmpeg -i {filename} -q:a 0 -map a sample.mp3" os.system(command)
Convert wav to mp3
import os list_of_commands = [ " -i dina.wav", # input file " -vn ", # disable video if any in the file "-ar 44100", # wav audio sampling frequency " -ac 2", # audio channels " -b:a 192k", # quality of mp3, converts audio bit rate to 192kbs " output.mp3" # output file ] command = "ffmpeg" + " ".join(list_of_commands) os.system(command)
Convert a single mp3 to wav
ffmpeg -i click.mp3 -acodec pcm_s16le -ac 1 -ar 16000 click.wav
List of devices
This script prints all the audio and video devices name you have on your computer. Useful when you want to record audio or video with ffmpeg, for example.
import os
os.system("ffmpeg -list_devices true -f dshow -i dummy")