Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2018-11-30 08:20:29 -0600

Nbb gravatar image

Error VideoWriter - not writing anything

I want to read video then write to different video. Below is my code but video writer does not save anything. Help pls.

import numpy as np
import cv2
from tqdm import tqdm

inp = "./videos/a"
out = "b"

inpcap = cv2.VideoCapture(inp+".MP4")
outcap = cv2.VideoWriter(out+".MP4", cv2.VideoWriter_fourcc('H','2','6','4'), 30, (int(inpcap.get(3)),int(inpcap.get(4))))

print(inp)
print(out)
print(int(inpcap.get(3)),int(inpcap.get(4)))

i = 1
pbar = tqdm(total = 80000)
while(inpcap.isOpened()):
    pbar.update(1)
    ret, frame = inpcap.read()
    if(ret == False):
        break
    outcap.write(frame)

inpcap.release()
outcap.release()