1

I would like to convert the command ffmpeg -i input.mp4 -i input.wav -c:v copy -map 0:v:0 -map 1:a:0 -c:a aac -b:a 192k output.mp4 to a Python function. How can I do this?

1 Answer 1

2

This is how I achieve it on Linux.

def ffmpeg():
    cmd = ["ffmpeg", "-i", "input.mp4", "-i",  "input.wav",  "-c:v", "copy",  "-map",  "0:v:0", "-map", "1:a:0",  "-c:a",  "aac",  "-b:a",  "192k",  "output.mp4"]
    
    ffmpeg = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
    
    # wait until the process completes
    ffmpeg.communicate()

or if you need to see the output replace with

ffmpeg = subprocess.Popen(cmd)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. Is there a way to write actual code instead of running the process?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.