I am getting this error while runnthe script as shown
TEST.py
from pydub import AudioSegment
wav_audio = AudioSegment.from_file("Broken Summer.m4a", format="m4a")
wav_audio.export("audio1.mp3", format="mp3")
The error is as shown below
C:\Python\lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
C:\Python\lib\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Traceback (most recent call last):
File "C:/Users/karti/Documents/Python Programs/ChatApplication/deezer.py", line 13, in <module>
wav_audio = AudioSegment.from_file("Broken Summer.m4a", format="m4a")
File "C:\Python\lib\site-packages\pydub\audio_segment.py", line 685, in from_file
info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
File "C:\Python\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Python\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Python\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
I got the solution. If you have installed ffmpeg or ffmpeg-python. Uninstall it. As it will not work Run this command
pip uninstall ffmpeg
pip uninstall ffmpeg-python
Now go to this link https://ffmpeg.org/download.html
Download ffmpeg from here and Install it in C:\ffmpeg Then go to Environment Variables and in Path add a new path as - C:\ffmpeg\bin As this path contains ffmpeg.exe And That's it
Now suppose you have TEST.m4a file that you want to convert to TEST.mp3 Simply Copy and Paste the file name and run the below script. Note: The bewlo .py file should be in the same directory as TEST.m4a or otherwise you will need to add the correct path in 'CurrentFileName' variable Now Simply Create a .py File and paste this code
import subprocess
CurrentFileName = 'TEST.m4a'
FinalFileName = 'TEST.mp3'
try:
subprocess.call(['ffmpeg', '-i', f'{CurrentFileName}', f'{FinalFileName}'])
except Exception as e:
print(e)
print('Error While Converting Audio')
ch = input('Press Enter to Close')
This worked Perfectly for me as I wanted. :) If I was not clear in the answer do let me know here or you can mail me - kartikeyvaish99@gmail.com