I wanted to convert mp4 files into mp3 files using ffmpeg using python only (no.exe program). I am actually downloading audio files through pytube but all of them get downloaded in mp4 format... and Hence looking looking a way to convert mp4 into mp3 using ffmpeg.
The terminal command for windows is like this ffmpeg -i 1.mp4 1.mp3
I want to know how can I achieve this in python code.
you can try this:-
import os
location = "/download/files/"#or something like that
mp4_file = location + "video.mp4"
mp3_file = location + "audio.mp3"
op = "ffmpeg -i {} -vm {}".format(mp4_file, mp3_file)
os.system(op)
os.system("afplay {}".format(mp3_file))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.