[英]How to convert mp4 into mp3 using ffmpeg (python)
I wanted to convert mp4 files into mp3 files using ffmpeg using python only (no.exe program).我想使用 ffmpeg 仅使用 python 将 mp4 文件转换为 mp3 文件(no.exe 程序)。 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.
我实际上是通过 pytube 下载音频文件,但它们都以 mp4 格式下载......因此寻找一种使用 ffmpeg 将 mp4 转换为 mp3 的方法。
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. windows 的终端命令是这样的
ffmpeg -i 1.mp4 1.mp3
我想知道如何在 python 代码中实现这一点。
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))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.