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
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)
1 Comment
mpourreza
Thanks for your answer. Is there a way to write actual code instead of running the process?