cv2 save video mp4

Solutions on MaxInterview for cv2 save video mp4 by the best coders in the world

showing results for - "cv2 save video mp4"
Cai
23 Jun 2018
1import numpy as np
2import cv2
3
4cap = cv2.VideoCapture(0)
5
6# Define the codec and create VideoWriter object
7#fourcc = cv2.cv.CV_FOURCC(*'DIVX')
8#out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
9out = cv2.VideoWriter('output.avi', -1, 20.0, (640,480))
10
11while(cap.isOpened()):
12    ret, frame = cap.read()
13    if ret==True:
14        frame = cv2.flip(frame,0)
15
16        # write the flipped frame
17        out.write(frame)
18
19        cv2.imshow('frame',frame)
20        if cv2.waitKey(1) & 0xFF == ord('q'):
21            break
22    else:
23        break
24
25# Release everything if job is finished
26cap.release()
27out.release()
28cv2.destroyAllWindows()
29
Elisa
14 Jun 2017
1import cv2
2import numpy as np
3import os
4
5image_folder = 'data-set-race-01'
6video_file = 'race-01.mp4'
7image_size = (160, 120)
8fps = 24
9
10images = [img for img in os.listdir(image_folder) if img.endswith(".jpg")]
11images.sort()
12
13out = cv2.VideoWriter(video_file, cv2.VideoWriter_fourcc(*'MP4V'), fps, image_size)
14
15img_array = []
16for filename in images:
17    img = cv2.imread(os.path.join(image_folder, filename))
18    img_array.append(img)
19    out.write(img)
20
21out.release()
22
queries leading to this page
store video opencvsave treated video opencvcv2 video savecv2 videowrite mp4how to get video output in pythonhow to save a video using cv2store video using cv2 in opythoncap read function pyhow to get video output with pythonhow to save a video locally with python save cv2 videocv2 write in mp4opencv video writer pythoncv2 save video mp4 pythonsave cv2 as videocv2 video writesave evideo in opencvopencv save videocv2 save video to file samplescv2 write mp4 videoopencv python videowriter examplesave video in opencv pythonsave video output to file pythonsave video in file open cvwrite video pythonhow to save a video in opencv pythonhow to write a video in opencv pythonhow to save a video pythonhow to save a cv2save video in cv2windows opencv save videosave video open cvsave video in python codewrite a video using cv2write video opencv pythonhow to save a video using opencvcv2 save video mp4cv2 write video in mp4how to save video using open cvpython write videovideowriter opencv pythoncv2 python videocapture read get property fourccwrite video in cv2save video in cv2 with soundsave video cv2save file cv2cv2 save videocv2 write a videoopencv write videocv2 save video to filecv2 write mp4video save in cv2save video opencvpython cv2 output as mp4write on cv2 framehow to save video in opencvread and write video opencv pythonopencv output aviopencv write video and it brokenvideowritter savehow to get the fourcc from a video using cv2 in pythoncv2 write videohow to copy video in opencvcv2 write mp4 examplecv2 save video mp4