I am trying to save video using XVID as codec and.avi format but every time I get a file of only 6KB and I am not able to play it. I am using lepton 3.5 cameras. How can I resolve this?
fourcc = cv2.VideoWriter_fourcc(*"XVID")
out = cv2.VideoWriter('output_' + str(i) + '.avi', fourcc, 9.0, (160, 120), True)
Please find the code below in which I am using it -
found_device = None
for device in CCI.GetDevices():
if device.Name.startswith("PureThermal"):
found_device = device
print(" found lepton device")
break
if not found_device:
print("Couldn't find lepton device")
else:
lep = found_device.Open()
ID = lep.sys.GetFlirSerialNumber()
print(ID)
for i in range(1):
cv2_cap = cv2.VideoCapture(1)
cv2_cap.set(3, 160)
cv2_cap.set(4, 120)
fourcc = cv2.VideoWriter_fourcc('M', 'J', 'P', 'G')
out = cv2.VideoWriter('output.avi', fourcc, 9.0, (160, 120), True)
cv2.namedWindow("lepton", cv2.WINDOW_NORMAL)
print("Running, ESC or Ctrl-c to exit...")
while True:
ret, img = cv2_cap.read()
if ret == False:
print("Error reading image")
break
cv2.imshow("lepton", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
I solved the issue by adding out.write(frame)
as below:
cv2_cap = cv2.VideoCapture(1)
cv2_cap.set(3, 160)
cv2_cap.set(4, 120)
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
out = cv2.VideoWriter("output.avi", fourcc, 9.0, (160, 120), True)
cv2.namedWindow("lepton", cv2.WINDOW_NORMAL)
print("Running, ESC or Ctrl-c to exit...")
while True:
ret, img = cv2_cap.read()
if ret == False:
print("Error reading image")
break
out.write(img)
cv2.imshow("lepton", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.