Coder Social home page Coder Social logo

ZeroDivisionError? about video2x HOT 12 CLOSED

k4yt3x avatar k4yt3x commented on August 12, 2024
ZeroDivisionError?

from video2x.

Comments (12)

k4yt3x avatar k4yt3x commented on August 12, 2024 1

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

from video2x.

kwsou avatar kwsou commented on August 12, 2024

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.

from video2x.

k4yt3x avatar k4yt3x commented on August 12, 2024

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

from video2x.

k4yt3x avatar k4yt3x commented on August 12, 2024

@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.

from video2x.

YachtSail avatar YachtSail commented on August 12, 2024

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.

from video2x.

YachtSail avatar YachtSail commented on August 12, 2024

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.

from video2x.

k4yt3x avatar k4yt3x commented on August 12, 2024

@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.

from video2x.

k4yt3x avatar k4yt3x commented on August 12, 2024

@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.

from video2x.

k4yt3x avatar k4yt3x commented on August 12, 2024

@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.

from video2x.

verbiate avatar verbiate commented on August 12, 2024

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

from video2x.

k4yt3x avatar k4yt3x commented on August 12, 2024

@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.

from video2x.

verbiate avatar verbiate commented on August 12, 2024

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.

from video2x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.