Avatar ·

Python and FFmpeg: create video with audio in one pass or otherwise speed up the process

📁 Advanced Python Topics, numpy, pip

Trying to make Python and FFmpeg work together under Windows.

I need to create one long video from a set of images and audio tracks (stored in the program's memory as numpy arrays).

I managed to do this in 2 passes:

  • first create a video file without an audio track,
  • then add audio to it, but I would like it to be more optimal and faster:

 

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

- creating video

ffmpeg -y -f s16le -acodec pcm_s16le -ar 44100 -ac 1 ^