Solved - ValueError: invalid literal for int() with base 10: '9222,\n\n'
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
Or more safe:
total_frames = int(framerate_output.strip().strip(','))
I'll have to test this on Linux, but if you want to do a pull request
On Thu, Jul 18, 2024, 3:32 PM Mykhailo @.***> wrote:
Or more safe:
total_frames = int(framerate_output.strip().strip(','))
— Reply to this email directly, view it on GitHub https://github.com/nadermx/backgroundremover/issues/143#issuecomment-2237379989, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYACXB7TVLOQ5YD5XYNI5LZNAJ6FAVCNFSM6AAAAABHACRYNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZXGM3TSOJYHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>