Python .avi 到 .mp4

Ale*_*dro 5 python ffmpeg video-processing

我需要一些 python 代码来实现这个函数。我已经在 Ubuntu 中安装了 ffmpeg。

def convert_avi_to_mp4(avi_file.avi):
   mp4_file = None
   #some code to do the job
   return mp4_file
Run Code Online (Sandbox Code Playgroud)

谢谢

abh*_*arg 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
Run Code Online (Sandbox Code Playgroud)

  • 这对我不起作用,我一直收到“没有这样的文件或目录”。我通过删除单引号解决了这个问题。 (3认同)