VidGear

Published onesixx on

https://abhitronix.github.io/vidgear/latest/

https://abhitronix.github.io/vidgear/latest/switch_from_cv/

video_input_path=''
video_output_path=''

# import required libraries
import cv2
from vidgear.gears import CamGear
from vidgear.gears import WriteGear

stream = CamGear(video_input_path).start() 

# Define WriteGear Object 
# with suitable output filename for e.g. `Output.mp4`
output_params={"-input_framerate":stream.framerate.real}
vid_writer = WriteGear(video_output_path, logging=True, **output_params) 

# loop over
while True:

    # read frames from stream
    frame = stream.read()

    # check for frame if Nonetype
    if frame is None:
        print("end of frame");break


    # {do something with the frame here}


    # write frame to writer
    vid_writer.write(frame)

    # check for 'q' key if pressed
    key = cv2.waitKey(1) & 0xFF
    if key == ord("q"):
        break

cv2.destroyAllWindows()  # close output window
stream.stop()            # safely close video stream
vid_writer.close()           # safely close writer
https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#IPython.display.Video
from IPython.display import Video
Video(video_output_path)
Categories: vision

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x