Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress bar #128

Closed
PlanPh opened this issue Feb 16, 2015 · 15 comments
Closed

Progress bar #128

PlanPh opened this issue Feb 16, 2015 · 15 comments
Labels
enhancement Positive change that does not change the API, i.e. improved performance, using less memory etc. feature-request Request for a new feature or additional functionality.

Comments

@PlanPh
Copy link

PlanPh commented Feb 16, 2015

Hi,

I am really fine with moviepy - its a really great toolbox! I´ve writed a prgramm with a GUI to cut some videos in a specific way. This works really well.
Now i want to display the status of the cutting process on the interface like its displayed on my ipython console. But unfortunally i am not able to display the progress bar on my GUI.
I´ve tried "verbose_print" - but i cant call it the correct way.
Does anybody know the solution?

Thanks a lot! P

@Zulko
Copy link
Owner

Zulko commented Feb 17, 2015

I don't know. Maybe the best is to ask the question on reddit/python, reddit/learnpython or stackoverflow. Your question would be: "How can I retrieve and display in a [Tkinter ?] GUI the progress bar printed in the console by the library tqdm ?"

@BAXTER001
Copy link

I made a patch that extends the *write_video methods with a parameter to specifying the filelike object tqdm writes to, makes it very simple to pipe the progress between threads/processes, would you be interested in a pull request for it?

@Zulko
Copy link
Owner

Zulko commented Feb 23, 2015

@BAXTER001 Thanks, but wouldn't it be simpler to run moviepy in a separate thread and get the stdout ? With your solution we would have to amend all the functions that use the progress bar at some point, in case someone needs to print it externally.

@mgaitan
Copy link
Collaborator

mgaitan commented Feb 23, 2015

That's interesting, but changing just the progress bar's file to we will have a kind "progress bar screenshots" as text, and to do get the actual data (current percentage, ETA, etc) we should parse it.

I guess that a better approach should be to pass an optional 'callable' to the the progressbar function that receive n, total, percentage, elapsed_str, left_str, rate on each loop. Then this callable could do anything, for example, print the to the stdout/stderr as currently do, update a widget in a GUI, etc.

This imply a pull-request to tqdm or, probably faster, handle this in our own way.

I could make a pull-request with this refactor. What do you think?

@BAXTER001
Copy link

@Zulko I avoided that out of the perhaps irrational unease of doing the sys.stdout replacement dance when the specificity of just the tqdm output on a per-clip basis was possible.

@mgaitan That does sound like a far cleaner and more useful method, in fact one could probably limit this to a setter on clip rather than altering all the existing methods.

@Zulko
Copy link
Owner

Zulko commented Mar 1, 2015

Ok, looks like we are progressing towards a solution. @BAXTER001 what do you mean by "setter on clip ?" I'd propose that, maybe that's what you and @mgaitan had in mind ?

clip.iterframe_callback = some_function # some_function(iframe, frame, number_of_frames)

then in the clip.iterframes method (which is used by write_videofile, write_gif, etc.) we would add clip.iterframe_callback(i, frame, nframes) before yielding the new frame of each loop. This could be used for recreating a progress bar somewhere else, and nicely enough could be used for debugging purpose. What do you think ?

@BAXTER001
Copy link

That's precisely the sort of method I was thinking of.

Rather than a providing a callback, perhaps providing a generator function to this method to be wrapped around the current generator() returned by iter_frames would be more powerful?

As demonstrated by the implementation of tqdm itself it lends itself to a clean encapsulation of rate limiting of the progress message output, along with being a nice place to put any generic raw frame hackery :)

@agalera
Copy link

agalera commented Aug 5, 2016

status?

@keikoro keikoro added the enhancement Positive change that does not change the API, i.e. improved performance, using less memory etc. label Feb 18, 2017
@justswim
Copy link
Contributor

justswim commented Mar 4, 2017

I am also interested in this, since it would be make it easier to display progress when using MoviePy outside of terminal.

@johnmatthewtennant
Copy link

I'm also interested in this

@keikoro keikoro added the feature-request Request for a new feature or additional functionality. label Nov 25, 2017
@cybertoast
Copy link

Was just going to start hacking the internal generator() in write_videofile, but it seems a callback for the progressbar would be incredibly helpful. A simple usecase is for a web-based view of the renderer, which would allow callback to save state to a local cache. Certainly some examples of these workflows would be helpful, perhaps?

@Zulko
Copy link
Owner

Zulko commented Dec 4, 2017

For my other projects I am using a new approach where you provide a "logger" which can be either a console progress bar, a notebook progress bar, or a link to some website's database:

https://github.com/Edinburgh-Genome-Foundry/Proglog

It is a bit young , but it may be worth using this strategy for moviepy too.

Any comments welcome :)

@cybertoast
Copy link

@Zulko - thanks much for the reference to proglog. Looks very interesting! Could you clarify - are you suggesting that tqdm just be replaced with proglog for the tqdm wrapper around the generator? Or even monkey-patch my use of moviepy with an updated iter_frames() that uses proglog?
Sorry, I'm just thinking through how this implementation would work, and figure it's worthwhile to write up an example that I can submit, in case others need to do something similar. Thanks!

@tburrows13
Copy link
Collaborator

#1020

@leo860607
Copy link

In my case
I aim to add prograss bar in tkinter.

First of all, I use "proglog" import "ProgressBarLogger".
Secondly, i comment the logger in "ffmpeg_audiowrite.py" line 160、176
Third step is to make "iter_chunks" in "AudioClip.py" sent back the size through logger
Last step is to make your own progressbar update through logger

ps. U can get progresssbar maximum by "fps*duration"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Positive change that does not change the API, i.e. improved performance, using less memory etc. feature-request Request for a new feature or additional functionality.
Projects
None yet
Development

No branches or pull requests