DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far...

Welcome! This is a Q&A website for computer programmers and users alike, focused on helping fellow programmers and users. Read more

What are you stuck on? Ask a question and hopefully somebody will be able to help you out!
+3 votes

In the video diet program there is an active wait using a while loop. I want to know if this will affect the process execution time greatly and if so what can I replace it with.

def update_progress_bar(proc, manager, path: str) -> None:
    pbar = None
        total = get_total_frames(proc)
        cont = 0
        pbar = initialize_progress_bar(manager, path)
        while True:
            progress = get_current_frame(proc)
            percent = progress / total * 100
            pbar.update(percent - cont)
            cont = percent
    except expect.EOF:
        if pbar is not None:

When is the loop supposed to end? Do one of get_current_frame or pbar.update raise a EOF exception?


You can time it and measure the difference. Do it once with ffmpeg (without your program), then redo with your program.

$ time ffmpeg ...
$ time ./ ...

1 Answer

+1 vote
Best answer

For context, I'm assuming this question is related to your other question Show progress bar of a ffmpeg video convertion.
You have spawn a separate process for ffmpeg, so this loop will not affect ffmpeg if this is your question. Your program and ffmpeg are two separate processes and if you have a multi core CPU they will execute in parallel. Nevertheless your program is busy in the loop and this does affect your process, if this is the question. If you don't want your process to be stuck reading the ffmpeg output you have to spawn a new thread.

selected by
Contributions licensed under CC0