Ask Your Question

Revision history [back]

Saving video from frames in with fourcc codec h264 and h265 with opencv

0

I am saving frames from live stream to a video with h264 codec. I tried this with openCV (versions 3.4 and 4.4) in python but I am not able to save it. I can save video in XVID and many other codecs but I am not successful in h264 and h265.

I am using windows opencv 4.4 in Python.

My sample code is as follow

    cap = cv2.VideoCapture(0)
    while(cap.isOpened()):    
     ret,frame = cap.read()
     if ret == True:
     width  = int(cap.get(3)) # float
     height = int(cap.get(4)) # float
     # fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))        
     fourcc = cv2.VideoWriter_fourcc(*'H264')
     out = cv2.VideoWriter(filename, fourcc, 30, (width,height)) 
     out.write(frame)
    out.release()

Can anyone help me how can I save video in h264 and h265.

Saving video from frames in with fourcc codec h264 and h265 with opencv

0

I am saving frames from live stream to a video with h264 codec. I tried this with openCV (versions 3.4 and 4.4) in python but I am not able to save it. I can save video in XVID and many other codecs but I am not successful in h264 and h265.

I am using windows opencv 4.4 in Python.

My sample code is as follow

    cap = cv2.VideoCapture(0)
    while(cap.isOpened()):    
     ret,frame = cap.read()
     if ret == True:
     width  = int(cap.get(3)) # float
     height = int(cap.get(4)) # float
     # fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))        
     fourcc = cv2.VideoWriter_fourcc(*'H264')
     out = cv2.VideoWriter(filename, fourcc, 30, (width,height)) 
     out.write(frame)
    out.release()

Can anyone help me how can I save video in h264 and h265.

I am saving frames from live stream to a video with h264 codec. I tried this with openCV (versions 3.4 and 4.4) in python but I am not able to save it. I can save video in XVID and many other codecs but I am not successful in h264 and h265.

I am using windows opencv 4.4 in Python.

My sample code is as follow

cap = cv2.VideoCapture(0)
while(cap.isOpened()):    
    ret,frame = cap.read()
    if ret == True:
    width  = int(cap.get(3)) # float
    height = int(cap.get(4)) # float
    # fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))        
    fourcc = cv2.VideoWriter_fourcc(*'H264')
    out = cv2.VideoWriter(filename, fourcc, 30, (width,height)) 
    out.write(frame)
out.release()

Can anyone help me how can I save video in h264 and h265.

Saving video from frames in with fourcc codec h264 and h265 with opencv

0

I am saving frames from live stream to a video with h264 codec. I tried this with openCV (versions 3.4 and 4.4) in python but I am not able to save it. I can save video in XVID and many other codecs but I am not successful in h264 and h265.

I am using windows opencv 4.4 in Python.

My sample code is as follow

    cap = cv2.VideoCapture(0)
    while(cap.isOpened()):    
     ret,frame = cap.read()
     if ret == True:
     width  = int(cap.get(3)) # float
     height = int(cap.get(4)) # float
     # fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))        
     fourcc = cv2.VideoWriter_fourcc(*'H264')
     out = cv2.VideoWriter(filename, fourcc, 30, (width,height)) 
     out.write(frame)
    out.release()

Can anyone help me how can I save video in h264 and h265.

I am saving frames from live stream to a video with h264 codec. I tried this with openCV (versions 3.4 and 4.4) in python but I am not able to save it. I can save video in XVID and many other codecs but I am not successful in h264 and h265.

I am using windows opencv 4.4 in Python.

My sample code is as follow

cap = cv2.VideoCapture(0)
while(cap.isOpened()):    
    ret,frame = cap.read()
    if ret == True:
    width  = int(cap.get(3)) # float
    height = int(cap.get(4)) # float
    # fourcc = int(cap.get(cv2.CAP_PROP_FOURCC))        
    fourcc = cv2.VideoWriter_fourcc(*'H264')
    out = cv2.VideoWriter(filename, fourcc, 30, (width,height)) 
    out.write(frame)
out.release()

Can anyone help me how can I save video in h264 and h265.