-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: How to get original video fps with VideoGear. #371
Comments
Thanks for opening this issue, a maintainer will get back to you shortly! In the meantime:
|
Hi @nidhi-jha01, there can be several reasons why it is slow, but stabilizing it, will surely won't produce real-time frames. The stabilizer as mentioned in the docs will have latency because it need certain amount of frames to be in memory before applying filter to stabilize it. And this latency is even worse with HD or high FPS frames. So my advise would be to at least downscale or divide the task into different module such as generating point cloud, saving video, stabilizing video etc., and maybe use multi-threading or multi-processing to make it faster, but still you have to comprise between performance and quality. Hope that helps. |
@abhiTronix While using VideoGear and WriteGear , the fps is cut down to half of the original FPS for videos of >= 60 fps. |
@nidhi-jha01 Okay, can you explain the complete pipeline, and what are the various tasks in your pipeline. |
@nidhi-jha01 also, can you elaborate "cut down to half of the original FPS", by whom? API or you manually before inputting? |
import required librariesfrom vidgear.gears import VideoGear Open suitable video stream, such as webcam on first index(i.e. 0)stream = VideoGear(source=file_name,stabilize=True,**options).start() Define WriteGear Object with suitable output filename for e.g.
|
@nidhi-jha01 The FPS reported will be slower because number of factors. Try these hacks:
cv2.namedWindow("Output Frame", cv2.WINDOW_NORMAL)
cv2.resizeWindow("Output Frame", 600, 700)
# cv2.imshow("REALTIME", frame)
# Show output window
cv2.imshow("Output Frame", frame)
# check for 'q' key if pressed
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
# import required libraries
from vidgear.gears.helper import reducer
from vidgear.gears.stabilizer import Stabilizer
from vidgear.gears import CamGear
from vidgear.gears import WriteGear
import cv2
# Open suitable video stream
stream = CamGear(source="unstabilized_stream.mp4").start()
# initiate stabilizer object with default parameters
stab = Stabilizer()
# Define writer with default parameters and suitable output filename for e.g. `Output.mp4`
writer = WriteGear(output="Output.mp4")
# loop over
while True:
# read frames from stream
frame = stream.read()
# check for frame if not None-type
if frame is None:
break
# reducer frames size if you want more performance
frame = reducer(frame, percentage=30) # reduce frame by 30%
# 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
# {do something with the stabilized frame here}
# write stabilized frame to writer
writer.write(stabilized_frame)
# clear stabilizer resources
stab.clean()
# safely close video stream
stream.stop()
# safely close writer
writer.close() |
@nidhi-jha01 But if you asking to get exact FPS as original it is impossible with |
Issue guidelines
Issue Checklist
Describe your Question
I need to process High-Resolution videos with Higher FPS (60 fps or above ) frame by frame and generate point cloud. When using VideoGear and WriteGear, the video is not showing up as its original fps . It is slow as compared to the original. Also adding stabilize in these videos makes it very slow. Can you help with this? Didn't find anything from issues and documentation.
Terminal log output(Optional)
No response
Python Code(Optional)
No response
VidGear Version
0.3.1
Python version
3.9
Operating System version
Windows 10
Any other Relevant Information?
No response
The text was updated successfully, but these errors were encountered: