I have write a code to record video in normal mp4 so far, but I think the video is compressed. How can I modify the code to record an uncompressed video? I remember the uncompressed video is codec in *'IYUV'
and the video extension should be .avi
import cv2
cam_ip = 'rtsp://admin:@192.168.0.129'
video_path = 'output.mp4'
in_gst = f"rtspsrc location={cam_ip} " \
f"! rtph264depay " \
f"! h264parse " \
f"! nvv4l2decoder " \
f"! nvvidconv " \
f"! video/x-raw, format=(string)BGRx " \
f"! videoconvert " \
f"! video/x-raw,format=BGR " \
f"! appsink drop=1"
v_cap = cv2.VideoCapture(in_gst, cv2.CAP_GSTREAMER)
out_gst = f"appsrc " \
f"! video/x-raw, format=BGR " \
f"! queue " \
f"! videoconvert " \
f"! video/x-raw,format=RGBA " \
f"! nvvidconv " \
f"! nvv4l2h264enc maxperf-enable=1 bitrate=9000000 " \
f"! h264parse " \
f"! mp4mux " \
f"! filesink location={video_path} "
writer = cv2.VideoWriter(out_gst, cv2.CAP_GSTREAMER, 0, 15, (3840, 2160))
frame_count = 0
while v_cap.isOpened():
ret_val, frame = v_cap.read()
if not ret_val:
break
writer.write(frame)
frame_count += 1
if frame_count == 15 * 3:
break