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

  • SEARCH
  • Home
  • 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 7967499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:56:07+00:00 2026-06-04T06:56:07+00:00

So I wrote a small python script that allows me to specify some folder

  • 0

So I wrote a small python script that allows me to specify some folder that contains video files, and some output directory, and the program loops over all the video files, and converts them using handbrake like:

proc = subprocess.Popen('HandBrakeCLI -i ... -o ...')
proc.wait()

So it does each file in the directory, one by one. I have a quad core machine, and want to speed things by doing video conversions in parallel but I don’t entirely understand how to approach that.

Do I need something like os.fork()? Something more like the multiprocessing module? I come from single threaded javascript land so this relatively new to me.

Thanks for any input!

  • 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-04T06:56:08+00:00Added an answer on June 4, 2026 at 6:56 am

    Something similar to this should do the trick:

    import multiprocessing
    ...
    def wrapper(currentfile):
        #create your commandline -- for the sake of simplicity, I assume that
        #the only thing that changes is the filename you are passing to
        #HandBrakeCLI (and that the filename is the last argument to pass)
        cmd='HandBrakeCLI -i ... -o ... '+currentfile 
        proc = subprocess.Popen(cmd)
        proc.wait()
        return 'foo'
    
    files=os.listdir(path)  #Any way that you build up your list of files is fine
    output = multiprocessing.Pool(4).map(wrapper,files) #output is ['foo', 'foo', ..., 'foo']
    

    Of course, this uses a map-like function for it’s side-effects which many python people dislike… but I find it to be intuitive enough — especially if you leave a comment. I also made the function return ‘foo’ to demonstrate that you can access the return value from the function quite easily.

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

Sidebar

Related Questions

I wrote a small program, that creates files at an interval of 1 minute.
I wrote a small script. It's designed to search the python directory for all
I wrote a small-ish Python script that handles nightly conversions and archiving of audio
The following (a small C program and a python script that calls it) behave
I just wrote a small python script that gets me all the groups on
I just started with python and wrote myself a nice, small script that uses
I have a small application that I wrote in python. Did some research on
I have a small issue with a python program that I wrote to extract
I am write a small python script to gather some data from a database,
Backup Script Please check the link above, I wrote this small script in python.

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.