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

ZeroDivisionError? #8

Closed
YachtSail opened this issue Aug 27, 2018 · 12 comments
Closed

ZeroDivisionError? #8

YachtSail opened this issue Aug 27, 2018 · 12 comments
Assignees
Labels
type:Bug Something isn't working

Comments

@YachtSail
Copy link

After the program finished processing all the frames, the following message appeared:
video:4418846kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[!] ERROR: An exception occurred
Traceback (most recent call last):
File "video2x.py", line 215, in
video2x()
File "video2x.py", line 150, in video2x
framerate = float(Fraction(info['streams'][0]['avg_frame_rate']))
File "C:\Python27\lib\fractions.py", line 162, in new
raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
ZeroDivisionError: Fraction(0, 0)

What could have caused this problem? Does this program require certain video coding format to run properly?

@kwsou
Copy link

kwsou commented Aug 27, 2018

Just experienced this exact issue a moment ago. The problem lies in trying to obtain the framerate of the video from an non-video stream.

I figure for most of the time, the videos being used have the video stream before the audio stream, so the hardcoded info['streams'][0] will work but if the audio stream is first, it will use the information in that stream, which will have a framerate of 0/0.

Older versions of this program would probably also experience this same error when they attempt to obtain the width/height from the first stream index as well.

This implementation does not also account for the case where you have multiple video streams inside the file.

The workaround I used for now was to change the stream index to 1 since my file had the video stream at that index instead. You could also just hardcode the framerate variable to a specific value. Not a real fix, but it's enough to get it working until this issue is resolved.

@k4yt3x k4yt3x self-assigned this Aug 29, 2018
@k4yt3x k4yt3x added the type:Bug Something isn't working label Aug 29, 2018
@k4yt3x
Copy link
Owner

k4yt3x commented Aug 29, 2018

@YachtSail thanks for the issue. Will take a look ASAP.

@k4yt3x
Copy link
Owner

k4yt3x commented Aug 29, 2018

@YachtSail
I looked at the error and saw this line:

File "C:\Python27\lib\fractions.py", line 162, in new

This software runs with Python3 which is declared in its shebang, where python2 is used in your case.
python command in the documentation doesn't define the version of Python, the code does.

It's my bad that I didn't make it clear enough. This is the only python program in my repository that's meant to be run under Windows environment. To avoid confusion I might change the documentation too. Try using python3 first and see if the issue remains.

Update

I have already update the installation instructions.

@k4yt3x k4yt3x added false positive This isn't a issue and removed type:Bug Something isn't working labels Aug 31, 2018
@YachtSail
Copy link
Author

The issue still remains after I change to python 3. I tried the method @kwsou provided and it did allow the program to finish, but the merged video has an audio sync issue. I can provide you the video I used for testing if you wish. Thank you for responding.

@YachtSail
Copy link
Author

Here is the error report:
[!] ERROR: An exception occurred
Traceback (most recent call last):
File "video2x.py", line 215, in
video2x()
File "video2x.py", line 150, in video2x
framerate = float(Fraction(info['streams'][0]['avg_frame_rate']))
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\fractions.py", line 178, in new
raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
ZeroDivisionError: Fraction(0, 0)
I have previously installed two versions of python. For this test, I uninstalled them all and reinstalled python 3 just to make sure everything works. It seems that the program ran in python 3 this time, but the ZeroDivisionError issue persists.

@k4yt3x
Copy link
Owner

k4yt3x commented Aug 31, 2018

@YachtSail Roger that. Thanks to @kwsou 's comment which I read carefully, I will look into the problem and see if I can get a quick fix.

Sorry but you might have to stick to @kwsou 's fix for the moment.

@k4yt3x k4yt3x added type:Bug Something isn't working and removed false positive This isn't a issue labels Aug 31, 2018
@k4yt3x
Copy link
Owner

k4yt3x commented Sep 1, 2018

@YachtSail @kwsou I will try to change from ffmpeg to ffmpeg-python and see if that will solve the problem. It should be a more elegant solution that just executing stuff from the commandline.

@k4yt3x
Copy link
Owner

k4yt3x commented Oct 22, 2018

@YachtSail @kwsou Sorry for taking so long. I've been busy with all the conferences and events that were going on.

I just pushed a beta solution for the problem, which should solve it. I'll make some test tonight when I get back to my relatively powerful workstation and test the results. You can take a look at the newest version if you want.

@k4yt3x k4yt3x closed this as completed Oct 23, 2018
@verbiate
Copy link

verbiate commented Aug 31, 2019

Seeing the error again on version 2.10.0:

[!] ERROR: An exception has occurred
Traceback (most recent call last):
  File "video2x.py", line 431, in <module>
    upscaler.run()
  File "E:\upscale\video2x-2.9.0-win32-full\video2x-master-batchfix\bin\upscaler.py", line 334, in run
    framerate = float(Fraction(video_info['streams'][video_stream_index]['avg_frame_rate']))
  File "C:\Program Files\Python37\lib\fractions.py", line 178, in __new__
    raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
ZeroDivisionError: Fraction(0, 0)

Interestingly, the line before says it's calling \bin\ffprobe.exe, but I'm running the Python scripts directly and that executable isn't located in \bin

@k4yt3x
Copy link
Owner

k4yt3x commented Aug 31, 2019

@verbiate /bin/ffprobe.exe? That sounds so *nix.
Try the newest version (2.10.0) instead of the release. The exe release isn't as up-to-date as the python source code. I might automate this packaging later using GitHub Actions so the exe is up to date. However, for now, I recommend you to try the python version as it fixed some problems in 2.9.0.

@verbiate
Copy link

verbiate commented Aug 31, 2019

As I mentioned, I am running 2.10.0, not 2.9.0.

Edit: Confusingly, I put the 2.10.0 folder inside the previous 2.9.0 folder when I was first testing it, which is why you see it in the path above. The script indicates it is indeed running 2.10.0 upon launch.

@k4yt3x
Copy link
Owner

k4yt3x commented Aug 31, 2019

@verbiate ok got it.
Could you please open a new issue for this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants