Closed jmraker closed 2 years ago
Just to make sure I understand correctly, you want the run_ffmpeg_show_progress
function to accept another argument which is a custom function that you make. So I change my function definition to:
def run_ffmpeg_show_progress(command, ffmpeg_loglevel="info", progress_handler=None)
You create a function that defines what to do with the percentage progress, speed and ETA:
def handle_progress_info(progress, speed, eta):
# blah blah...
And then you call my function like so:
def run_ffmpeg_show_progress(command, ffmpeg_loglevel="info", progress_handler=handle_progress_info)
I'll add this ability and let you know when the update has been pushed.
Yes, if that's the best python way. I'm not a python expert but I was thinking the parameters could be an object. If you have the need to add more info to it, hopefully if wouldn't automatically break the callback that way.
def handle_progress_info(progress):
if (progress.percent > 50):
blah()
if(progress.eta > 1000 * 60): # Don't wait more than 1000 hours!
progress.process.terminate()
Update pushed. Run pip3 install --upgrade better-ffmpeg-progress
to test and check out the updated README as the way to use this module has changed: https://github.com/CrypticSignal/better-ffmpeg-progress#readme
Let me know if this new feature works as you want it to.
Adding an optional callback/event that passes the 3+ numbers (and maybe the process handle) when needed might be useful for those who want to customize the output to . Add ANSI colors . Put the info into a GUI . Reword/translate something or represent it as ASCII art. . Remove or re-arrange things