Python .avi转换为.mp4

5

我需要一些关于这个功能的Python代码。我已经在Ubuntu上安装了FFmpeg。

def convert_avi_to_mp4(avi_file.avi):
   mp4_file = None
   #some code to do the job
   return mp4_file

Thank you

1个回答

6
你可以像这样做...
import os

def convert_avi_to_mp4(avi_file_path, output_name):
    os.popen("ffmpeg -i '{input}' -ac 2 -b:v 2000k -c:a aac -c:v libx264 -b:a 160k -vprofile high -bf 0 -strict experimental -f mp4 '{output}.mp4'".format(input = avi_file_path, output = output_name))
    return True

3
这对我没有起作用,我一直收到“没有这样的文件或目录”的错误信息。 我通过去掉单引号来解决了这个问题。 - Water Man

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接