AdamSpannbauer / python_video_stab

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

No output video #80

Closed evgdobr closed 5 years ago

evgdobr commented 5 years ago

Describe the bug No output video file created. The next script run doesn't generate any output video file, but plots are shown (correct plots).

Provide version info What version of Python are you running? Python 3.7.3 What version of OpenCV are you running? >>> cv2.version '4.1.0' What version of vidstab are you running? The last one OS: Windows 10

Provide error message No error message shown

Provide code snippet import matplotlib.pyplot as plt from vidstab import VidStab in_video = r'C:\Desktop\4.avi' out_video = r'‪C:\Desktop\4_stab.avi' stabilizer = VidStab() stabilizer.stabilize(input_path=in_video, output_path=out_video) stabilizer.plot_trajectory() plt.show() stabilizer.plot_transforms() plt.show()

Are you able to provide the video? any video )

AdamSpannbauer commented 5 years ago

Hi @evgdobr thanks for reporting the issue.

I tried recreating your issue on my windows machine with the below script. The script seemed to process without issue. Could you please confirm that your issue persists when running the below script on your machine?

Script

import os
import sys
import cv2
import vidstab

print(f'sys.version:\n{sys.version}\n')
print(f'vidstab version: {vidstab.__version__}')
print(f'cv2 version:     {cv2.__version__}')

work_dir = '.'
in_video = os.path.join(work_dir, 'video_in.avi')
out_video = os.path.join(work_dir, 'video_out.avi')

vidstab.download_ostrich_video(in_video)

if os.path.exists(out_video):
    os.remove(out_video)

print(f'Output file exists (pre-stab):  {os.path.exists(out_video)}')
stabilizer = vidstab.VidStab()
stabilizer.stabilize(input_path=in_video, output_path=out_video)
print(f'Output file exists (post-stab): {os.path.exists(out_video)}')

Console Output

sys.version:
3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)]

vidstab version: 1.6.2
cv2 version:     4.1.0
Output file exists (pre-stab):  False
Output file exists (post-stab): True
evgdobr commented 5 years ago

Hi @AdamSpannbauer , thanks for your answer!

the output is below, and it works fine for downloaded ostrich video.

C:\Users\idobrovolskyi\AppData\Local\Programs\Python\Python37-32\python.exe D:/Repo/my_pet_prj/video_stab sys.version: 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] vidstab version: 1.6.2 cv2 version: 4.1.0 Output file exists (pre-stab): False Output file exists (post-stab): True

Process finished with exit code 0

then i had commented line vidstab.download_ostrich_video(in_video) and replaced in_video with my video. The result is the same :) So it works if video files are located in script dir.

AdamSpannbauer commented 5 years ago

To clarify, I'm able to change the location of the work_dir and the processing still work as intended (see below screenshot). At this point, I'm not sure what else to try to recreate this issue for debugging.

image

evgdobr commented 5 years ago

you should not change work dir, just put in_video and out_video somewhere out of the workdir

AdamSpannbauer commented 5 years ago

I think you misunderstood my intention when I said: "change the location of the work_dir". I didn't mean I changed the working directory (akin to os.chdir()), but rather that I changed the value of the work_dir variable in the script I posted (i.e. that the videos were loaded/saved outside of the working directory).

That's my fault on poor variable naming. The work_dir variable in my debug script should probably be named video_location or something like that.

AdamSpannbauer commented 5 years ago

Hi @evgdobr, any follow-up on this? Does the debug script I shared work on your machine even if you change the value of the work_dir variable?

evgdobr commented 5 years ago

hi, yes, it works, hence the problem is in my video

AdamSpannbauer commented 5 years ago

Would you be comfortable sharing the video? I'd be happy to help debug the issue if I can recreate it. I, of course, understand if you'd rather not share the input video.

evgdobr commented 5 years ago

Would you be comfortable sharing the video? I'd be happy to help debug the issue if I can recreate it. I, of course, understand if you'd rather not share the input video.

i had sent it yo your e-mail.