Python .avi 转 .mp4

5 投票
1 回答
23147 浏览
提问于 2025-04-18 00:34

我需要一些Python代码来实现这个功能。我已经在Ubuntu上安装了ffmpeg。

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

谢谢

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

撰写回答