i'm trying to write a script to record camera display.
When i tried to run, i got the error:
OpenCV: FFMPEG: tag 0x5634504d/'MP4V' is not supported with codec id 12 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
Here's my code:
import cv2
cam = cv2.VideoCapture(0)
width = int(cam.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cam.get(cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc(*"MP4V")
writer = cv2.VideoWriter("captures/record.mp4", fourcc, 20, (width, height))
while True:
is_camera_working, display = cam.read()
cv2.imshow("Camera Data", display)
if cv2.waitKey(25) & 0xFF == ord("q"):
break
cam.release()
writer.release()
cv2.destroyAllWindows
I tried to write (*"mp4v")
, ("m","p","4","v")
in the VideoWriter_fourcc
. Also i delete fourcc
variable and just write 0x7634706d
as second argumnet of VideoWriter
function.
I saw this and this threads. Still not works for me.
What is the problem and how can i solve it? Thanks in advance.
I just realise that i didn't write writer.write(display)
in the while loop. It works now. Thanks everyone for their time!