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

Solved - ValueError: invalid literal for int() with base 10: '9222,\n\n' #143

Open
wayne931121 opened this issue Apr 30, 2024 · 0 comments

Comments

@wayne931121
Copy link

Good Job.

(yolov8) C:\Users\s\Desktop\文件\project>backgroundremover -i "C:\Users\s\Downloads\VID20240430173530.mp4" -tv -o "output.mov"
Traceback (most recent call last):
  File "C:\Users\s\anaconda3\envs\yolov8\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\s\anaconda3\envs\yolov8\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\s\anaconda3\envs\yolov8\Scripts\backgroundremover.exe\__main__.py", line 7, in <module>
    sys.exit(main())
  File "C:\Users\s\anaconda3\envs\yolov8\lib\site-packages\backgroundremover\cmd\cli.py", line 196, in main
    utilities.transparentvideo(os.path.abspath(args.output.name), os.path.abspath(args.input.name),
  File "C:\Users\s\anaconda3\envs\yolov8\lib\site-packages\backgroundremover\utilities.py", line 241, in transparentvideo
    matte_key(temp_file, file_path,
  File "C:\Users\s\anaconda3\envs\yolov8\lib\site-packages\backgroundremover\utilities.py", line 92, in matte_key
    total_frames = int(framerate_output)
ValueError: invalid literal for int() with base 10: '9222,\n\n'

So I just change utilities.py line 92

    framerate_output = sp.check_output(cmd, universal_newlines=True)
    total_frames = int(framerate_output)

to
https://stackoverflow.com/questions/25359288/how-to-know-total-number-of-frame-in-a-file-with-cv2-in-python

    import cv2

    cap = cv2.VideoCapture(file_path)
    total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
    
    #framerate_output = sp.check_output(cmd, universal_newlines=True)
    #total_frames = int(framerate_output)

The error is:

ValueError: invalid literal for int() with base 10: '9222,\n\n'

The total frames is 9222, so you can use

total_frames = int(framerate_output.split(",")[0])

or use OpenCV to get frames.

System Windows11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant