Python .avi to .mp4

14,562

you can do something like this..

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
Share:
14,562
Alejandro
Author by

Alejandro

Updated on June 16, 2022

Comments

  • Alejandro
    Alejandro about 2 years

    I need some python code for this function. I have installed ffmpeg in Ubuntu.

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

    Thank you

  • Water Man
    Water Man almost 4 years
    This didn't work for me and I kept getting "No such file or directory". I fixed this by removing the single quotes.