zion.b.
zion.b.

Reputation: 71

Converting mp4 AAC to AVC using Python

i am using ffmpeg to convert video format. I have a video in mp4 aac and want to convert it to mp4 avc. I successfully(!!!) used ffmpeg to covert image to avi/mkv/even copy of the mp4 but nothing gives me what i desire.

The idea is to have a video file format that will run on mostly all mobile devices such as mp4 avc.

My python code:

import subprocess #need to install ffmpegin terminal/cmd

def convert_video(video_input, video_output):
    cmds = ['ffmpeg', '-i', video_input, video_output]
    subprocess.Popen(cmds)


convert_video("videoName.mp4", "videoNameCopy.mp4")

Upvotes: 0

Views: 1124

Answers (1)

Exosylver
Exosylver

Reputation: 166

It seems that you want to convert your VIDEO codec from hevc to h.264 (a.k.a avc bp):

import subprocess
    def convert_video(video_input, video_output):
    subprocess.run(rf" -i video_input -c:v libx264 -c:a aac video_output")

convert_video("users/vids/.../input.mp4", "users/vids/.../output.mp4")

This converts the video and keeps the audio.

Upvotes: 1

Related Questions