Avatar ·

Python and FFMPEG: Create a video with audio in one pass or otherwise speed up the process

📁 Advanced Python Topics, numpy, pip

Trying to make friends Python and FFMPEG under Windows.

It is necessary from a set of images and sound tracks (stored in the memory of the program as Numpy Array) to make one long video.

I could do this in 2 passes:

  • First I create a video from images via pipe,
  • Then I add audio to it, but I would like something more optimal and faster:

& nbsp;

  ffmpeg -y -f rawvideo -vcodec rawvideo -s 1920x1080 -pix_fmt bgr24 -r  5.00  ^ -i pipe:  0  -vcodec libx264 -preset medium -pix_fmt yuv420p video.avi  

- I create a video

  ffmpeg -f s16le -acodec pcm_s16le -ar  44100  -ac  2  -i pipe:  0  -i video.avi -c:v copy -c:a aac -strict experimental output.mp4  

- Then I add audio. Is it possible to combine these two commands into one, so that the video and audio are created simultaneously in one pass? Or are there other ways to speed up the process?