AdamSpannbauer / python_video_stab

A Python package to stabilize videos using OpenCV
https://adamspannbauer.github.io/python_video_stab/html/index.html
MIT License
696 stars 120 forks source link

Throw exception if input video file doesn't exist. #71

Closed AdamSpannbauer closed 5 years ago

AdamSpannbauer commented 5 years ago

Current behavior

When the input video path doesn't exist, VidStab throws IndexError: pop from an empty deque (see error message in #70 for example)

Desired behavior:

If the input video doesn't exist VidStab should throw an exception notifying the user that video doesn't exist.

studiophile commented 5 years ago

I am unable to get past this error.

raise " FileNotFoundError(f'{input_path} does not exist')"

I verified the path and file exist with os.path.isfile(). The file is there and is being properly fed. I initally thought maybe it was a unicode string issue, but I have even tried hard coding the file path into VidStab.py, but still cannot seem to make it past this error. Is there specific file type limitations?
Or is this a versioning issue? I am running Python 3.5.1 + vidstab 1.60

studiophile commented 5 years ago

I forgot to mention, this is poping up as a invalid syntax err

https://user-images.githubusercontent.com/25994608/60456663-b3a57e80-9bee-11e9-86c5-a055859f33a3.JPG

studiophile commented 5 years ago

I was able to get past this error by changing the string formatting to old method from 3.5.1 raise FileNotFoundError('%s does not exist' % input_path) https://www.python.org/dev/peps/pep-0498/

AdamSpannbauer commented 5 years ago

Given the syntax error and that it was fixed by converting the string interpolation to the % method, I'm questioning if the Python 3.5.1 installation was running the code or if a lingering 2.x installation was.

Could you try running the below code snippet using the same method you were using to call the failing vidstab process? It should prove out the versioning. Additionally, if the error persists, we'll be working from the same input video which should make debugging easier.

import sys
import vidstab

print('Python version')
print(sys.version, end='\n\n')

print('vidstab version')
print(vidstab.__version__)

test_video_path = 'ostrich.mp4'
vidstab.download_ostrich_video(test_video_path)

stabilizer = vidstab.VidStab()
stabilizer.stabilize(input_path=test_video_path, output_path='test_output.avi')

P.S. Notifications for comments on closed issues are quieter than notifications of opening up a new issue. In this case, I noticed your comment, but it would be easy for it to slip through the cracks. In the future, if you remember, please open a new issue so I won't accidentally leave your issue unattended. Thanks for reporting the issue!

AdamSpannbauer commented 5 years ago

@studiophile any follow-up on this issue? Doing some clean-up and I plan to close this soon if no response.