Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8806565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:09:27+00:00 2026-06-14T02:09:27+00:00

My work recently involves programmatically making videos. In python, the typical workflow looks something

  • 0

My work recently involves programmatically making videos. In python, the typical workflow looks something like this:

import subprocess, Image, ImageDraw

for i in range(frames_per_second * video_duration_seconds):
    img = createFrame(i)
    img.save("%07d.png" % i)

subprocess.call(["ffmpeg","-y","-r",str(frames_per_second),"-i", "%07d.png","-vcodec","mpeg4", "-qscale","5", "-r", str(frames_per_second), "video.avi"])

This workflow creates an image for each frame in the video and saves it to disk. After all images have been saved, ffmpeg is called to construct a video from all of the images.

Saving the images to disk (not the creation of the images in memory) consumes the majority of the cycles here, and does not appear to be necessary. Is there some way to perform the same function, but without saving the images to disk? So, ffmpeg would be called and the images would be constructed and fed to ffmpeg immediately after being constructed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:09:29+00:00Added an answer on June 14, 2026 at 2:09 am

    Ok I got it working. thanks to LordNeckbeard suggestion to use image2pipe. I had to use jpg encoding instead of png because image2pipe with png doesn’t work on my verision of ffmpeg. The first script is essentially the same as your question’s code except I implemented a simple image creation that just creates images going from black to red. I also added some code to time the execution.

    serial execution

    import subprocess, Image
    
    fps, duration = 24, 100
    for i in range(fps * duration):
        im = Image.new("RGB", (300, 300), (i, 1, 1))
        im.save("%07d.jpg" % i)
    subprocess.call(["ffmpeg","-y","-r",str(fps),"-i", "%07d.jpg","-vcodec","mpeg4", "-qscale","5", "-r", str(fps), "video.avi"])
    

    parallel execution (with no images saved to disk)

    import Image
    from subprocess import Popen, PIPE
    
    fps, duration = 24, 100
    p = Popen(['ffmpeg', '-y', '-f', 'image2pipe', '-vcodec', 'mjpeg', '-r', '24', '-i', '-', '-vcodec', 'mpeg4', '-qscale', '5', '-r', '24', 'video.avi'], stdin=PIPE)
    for i in range(fps * duration):
        im = Image.new("RGB", (300, 300), (i, 1, 1))
        im.save(p.stdin, 'JPEG')
    p.stdin.close()
    p.wait()
    

    the results are interesting, I ran each script 3 times to compare performance:
    serial:

    12.9062321186
    12.8965060711
    12.9360799789
    

    parallel:

    8.67797684669
    8.57139396667
    8.38926696777
    

    So it seems the parallel version is faster about 1.5 times faster.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently in our work, I've started getting some experience with SEO (finally). It's something
Firefox recently blacklisted the plugin that allows xbaps to work in firefox This is
I've been doing lots of work recently on the new Workflow 4.0. One of
Hi I am recently work with Leaves api and I have problem with this
I recently did some work modifying a Python gui app that was using wxPython
We've recently upgraded one of our projects. This involves new versions of JARs also.
Having spent a bunch of time recently doing 2D work that involves pixel manipulation
I found this little gem in our codebase at work recently. I have to
An application I have recently started work on has to register two dll's, because
I ran across some code recently at work (recreated to be similar to what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.