vidgear
vidgear copied to clipboard
[Bug]: Stabilization not good on linux environment
Description
Video gets even more unstable after stabilizing it on linux, while the same stabilized video looks fine on windows
Issue Checklist
- [X] I have searched open or closed issues for my problem and found nothing related or helpful.
- [X] I have read the Documentation and found nothing related to my problem.
- [X] I've read the Issue Guidelines and wholeheartedly agree.
Expected behaviour
i expected the stabilized video coming out like this on linux, which is what it does on windows
https://github.com/user-attachments/assets/8b20bb81-3f66-40d1-9ae6-591fac188940
Actual behaviour
the actual stabilized video looks like this
https://github.com/user-attachments/assets/0d60b6e4-04e1-48d8-a246-28484a986c8a
Steps to reproduce
I used the below python code to process the files
Terminal log output
No response
Python Code(Optional)
from vidgear.gears.stabilizer import Stabilizer
import cv2
import time
import logging
logger = logging.getLogger(__name__)
logger.setLevel(level=3)
stab = Stabilizer(border_size=10, crop_n_zoom=True, logging=True)
def stabilize_video(input_path, output_path):
start_time = time.time()
stream = cv2.VideoCapture(input_path)
# Get video properties
fps = int(stream.get(cv2.CAP_PROP_FPS))
width = int(stream.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(stream.get(cv2.CAP_PROP_FRAME_HEIGHT))
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
while True:
# read frames from stream
(grabbed, frame) = stream.read()
if not grabbed:
break
# send current frame to stabilizer for processing
stabilized_frame = stab.stabilize(frame)
# wait for stabilizer which still be initializing
if stabilized_frame is None:
continue
out.write(stabilized_frame)
# clear stabilizer resources
stab.clean()
# safely close video stream
stream.release()
out.release()
logger.info(f"Stabilization completed in {time.time() - start_time} seconds.")
return True
VidGear Version
0.3.3
Python version
3.11.9
OpenCV version
opencv-python-headless-4.8.0.74
Operating System version
wsl Ubuntu-22.04
Any other Relevant Information?
No response