0

I'm trying to combine an image with an audio file and convert them to mp4. I found this command line and I used it. It works perfectly.

ffmpeg -loop 1 -i 01_Prologue.png -i 01_Prologue.wav -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest out.mp4

I want to use python because I want to combine multiple images with multiple audio files

I used this code to combine the same audio and image files but it gave me a blank video file.

import ffmpeg

input_still = ffmpeg.input("image.jpg")
input_audio = ffmpeg.input("audio.wav")

(
ffmpeg
.concat(input_still, input_audio, v=1, a=1)
.output("output.mp4")
.run(overwrite_output=True)
)

I'm guessing that is because I didn't add the filters to the code, and the problem happened.

but how to do it?

  • 1
    So do you want to convert *any* ffmpeg command to python, or are you trying to debug this ffmpeg command? I'd recommend clarifying the title correspondingly. – The Matt Jan 02 '23 at 00:49
  • You may use subprocess module: `subprocess.run(shlex.split('ffmpeg -loop 1 -i 01_Prologue.png -i 01_Prologue.wav -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest out.mp4'))`. In case you are asking about ffmpeg-python usage, please show a better effort (we don't suppose to use `concat` filter - it may work, but the command supposed to look closer to the original command line). – Rotem Jan 02 '23 at 09:28

0 Answers0