Closed korabelnikov closed 4 years ago
short investigation shows me that path was wrong. So we just need one assert to prevent such cases
Hi, @korabelnikov I apologize for the delay in responding to this.
A clarifying statement about what you mean when you say the path was wrong. Do you mean that the path_in
was referencing a file that didn't exist and that the assert os.path.exists(path_in)
statement fixed the issue?
@korabelnikov I've been unable to reproduce the error using the below script. The script identifies that the input file doesn't exist and throws the exception shown below the code block. Am I going about reproducing your issue wrong? Would you please advise? Thanks.
from vidstab import VidStab
# Path that does not exist
fake_path = 'fakerino.mp4'
output_path = 'doesnt_matter.mp4'
stabilizer = VidStab()
stabilizer.stabilize(input_path=fake_path, output_path=output_path)
Traceback (most recent call last): File "/Users/aspannbauer/Documents/github/python_video_stab/reproduce_95.py", line 8, in <module> stabilizer.stabilize(input_path=fake_path, output_path=output_path) File "/Users/aspannbauer/Documents/github/python_video_stab/vidstab/VidStab.py", line 479, in stabilize raise FileNotFoundError(f'{input_path} does not exist') FileNotFoundError: fakerino.mp4 does not exist
@AdamSpannbauer what OS you use?
Under linux (ubuntu) I got the error
I personally tested on macOS Catalina v10.15.1, and there is also a unit test for an invalid path and the tests are being run by Travis CI on Ubuntu (last build was on Ubuntu 16.04.6 LTS). This test is also passing, so I'm not sure what next steps would be.
To confirm, if you run the same exact code block I posted in my last message, you get an error about deque index rather than a FileNotFoundError
?
I've re-checked file exists but it's empty. Sorry, for that
Interesting. I'll look into outputting a more informative error message for this case.
Code to reproduce error:
from pathlib import Path
from vidstab import VidStab
empty_path = 'empty.mp4'
output_path = 'doesnt_matter.mp4'
Path(empty_path).touch()
stabilizer = VidStab()
stabilizer.stabilize(input_path=empty_path, output_path=output_path)
Relevant portion of traceback
File "/Users/aspannbauer/Documents/github/python_video_stab/reproduce_95.py", line 10, in <module> stabilizer.stabilize(input_path=empty_path, output_path=output_path) File "/Users/aspannbauer/Documents/github/python_video_stab/vidstab/VidStab.py", line 501, in stabilize bar = self._init_trajectory(smoothing_window, max_frames, show_progress=show_progress) File "/Users/aspannbauer/Documents/github/python_video_stab/vidstab/VidStab.py", line 158, in _init_trajectory self._process_first_frame() File "/Users/aspannbauer/Documents/github/python_video_stab/vidstab/VidStab.py", line 140, in _process_first_frame prev_frame = self.frame_queue.frames[-1] IndexError: deque index out of range
Assuming #98 CI passes. A more informative error message has been added for this case. The below code will result in a ValueError
.
from pathlib import Path
from vidstab import VidStab
empty_path = 'empty.mp4'
output_path = 'doesnt_matter.mp4'
Path(empty_path).touch()
stabilizer = VidStab()
stabilizer.stabilize(input_path=empty_path, output_path=output_path)
ValueError: First frame is None. Check if input file/stream is correct.
Describe the bug Failed code sample
Provide version info What version of Python are you running? 3.7.5 What version of OpenCV are you running? 4.1.2 What version of vidstab are you running? master
Provide error message
Provide code snippet
Edited by @AdamSpannbauer for some formatting stuff.