CrypticSignal / better-ffmpeg-progress

A Python package that allows you to run an FFmpeg command & see percentage progress, ETA, etc.
https://pypi.org/project/better-ffmpeg-progress
MIT License
54 stars 16 forks source link

[Error] float division by zero #7

Closed janciev closed 1 year ago

janciev commented 1 year ago

Hi,

when I run the script with the progress_handler I see the error message:

(env) [xxxx]$ /Users/[xxxx]/env/bin/python [xxxx]test_runner.py Running: ffmpeg -y -i [xxxx] -c:a libmp3lame -y output.mp3 -loglevel verbose -progress pipe:1 -nostats 0%| | 0/384.304 [00:00<?, ?s/s] [Error] float division by zero Exiting Better FFmpeg Progress.

The code below:

from better_ffmpeg_progress import FfmpegProcess

def handle_progress_info(percentage): print(f"The FFmpeg process is {percentage}% complete. ETA is / seconds.")

process = FfmpegProcess(["ffmpeg", "-i", "[xxxx]", "-c:a", "libmp3lame", "-y", "output.mp3"], ) process.run(progress_handler=handle_progress_info)

janciev commented 1 year ago

better-ffmpeg-progress==2.0.5 ffmpeg-python==0.2.0 future==0.18.2 tqdm==4.64.1

CrypticSignal commented 1 year ago

What might be the issue is that the duration of your file was incorrectly determined to be 0, in which case division by 0 will occur on this line.

I'll add a conditional to only run (seconds_processed / self._duration_secs) * 100 if self._can_get_duration is True. I'll let you know when I have added this change, after which please upgrade to the latest version of better-ffmpeg-progress and let me know if this fixes the issue.

CrypticSignal commented 1 year ago

Can you upgrade to version 2.0.6 with pip3 install better-ffmpeg-progress --upgrade and let me know if this fixes the issue?