Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ZeroDivisionError
#1
I am working on somebody's GitHub project and trying to run it produces this. I changed the time_delta = 1./fps to time_delta == 1./fps but I only got NameError: name 'time_delta' is not defined. I cannot figure out why fps == 0 for sure, but I think it is because the script cannot find the frames per second for the video. You can see what I mean here. I guess to reproduce this issue you need to install it and then use video-to-ascii -f {file}.mp4. It gives me this error because it cannot find the FPS of the video.

I would appreciate any help I can get, so that I can make a pull request to fix this issue.

Thanks in advance :) (and sorry for my horrible formatting)

Error:
video-to-ascii -f retail.mp4 Traceback (most recent call last): File "/home/mycatcondo3028/.local/bin/video-to-ascii", line 10, in <module> sys.exit(main()) File "/home/mycatcondo3028/.local/lib/python3.7/site-packages/video_to_ascii/cli.py", line 21, in main player.play(ARGS.file, strategy=ARGS.strategy, output=ARGS.output, play_audio=ARGS.with_audio) File "/home/mycatcondo3028/.local/lib/python3.7/site-packages/video_to_ascii/player.py", line 23, in play engine.play(output) File "/home/mycatcondo3028/.local/lib/python3.7/site-packages/video_to_ascii/video_engine.py", line 38, in play with_audio=self.with_audio) File "/home/mycatcondo3028/.local/lib/python3.7/site- packages/video_to_ascii/render_strategy/ascii_strategy.py", line 113, in render time_delta = 1./fps ZeroDivisionError: float division by zero
I don't know what to do, because whatever I do still produces this error.

Here is the part of the code by the way:
if output is not None:
           file = open(output, 'w+')
           file.write("#!/bin/bash \n")
           file.write("echo -en '\033[2J' \n")
           file.write("echo -en '\u001b[0;0H' \n")

       time_delta = 1./fps
       counter=0
       sys.stdout.write("echo -en '\033[2J' \n")
       # read each frame
buran write Nov-18-2020, 11:55 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
(Nov-17-2020, 08:32 PM)MyCatCondo Wrote: I guess to reproduce this issue you need to install it and then use video-to-ascii -f {file}.mp4.

Hi MyCatCondo,

You are asking an awful lot of the strangers you are soliciting for advice. Unless I overlooked it (and I apologize if I did!), you didn't even give us a link to the repo you are asking us to install. If you aren't sure why the variable fps is getting a value of zero, maybe showing us the code where that value is assigned would be helpful.

FYI, regarding the code change you mentioned... Changing an assignment operator (=) to a comparison operator (==) can't possibly help with a ZeroDivisionError, because you can't divide by 0 regardless of your reason for doing so.
Reply
#3
(Nov-17-2020, 09:33 PM)GOTO10 Wrote:
(Nov-17-2020, 08:32 PM)MyCatCondo Wrote: I guess to reproduce this issue you need to install it and then use video-to-ascii -f {file}.mp4.

Hi MyCatCondo,

You are asking an awful lot of the strangers you are soliciting for advice. Unless I overlooked it (and I apologize if I did!), you didn't even give us a link to the repo you are asking us to install. If you aren't sure why the variable fps is getting a value of zero, maybe showing us the code where that value is assigned would be helpful.

FYI, regarding the code change you mentioned... Changing an assignment operator (=) to a comparison operator (==) can't possibly help with a ZeroDivisionError, because you can't divide by 0 regardless of your reason for doing so.

Sorry about that! Here is the repo: https://github.com/joelibaceta/video-to-ascii
You can also use pip install video-to-ascii
Reply
#4
I didn't install this, but it looks like the fps variable is derived from the video being captured using the opencv-python module. I don't think there is any coding error here, it just seems like the capture is not working correctly on your system for whatever reason. Your best bet would probably be to reach out to the owners of this repo, or to read up on opencv-python and get that working independently before you try the broader code. If you haven't already, maybe try a different video file as input in case there is a problem there.

For the ZeroDivisionError, you could always just manually change the assignment statement in ascii_strategy.py by commenting out the current statement and using
fps = 30
in its place. That would avoid the ZeroDivisionError, but I'm sure you'd run into other issues. Good luck!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020