Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4906

Camera board • Re: "Or Better"?

$
0
0


I'm recording 1500 x 1500 @ 15fps on the pi5.
After recording, the bottleneck is the FFMPEG process of placing the 2 videos in a SBS format. It's about 1 frame per second.
Pardon? You're postprocessing two independent clips to create your video? Why?
sandyol has already provided you with picamera2 code that merges the two raw frames prior to encoding, and that requires no further processing.
I assume you are referring to this code, which I'll try when the Pi5 gets here:

Code:

#!/usr/bin/python3# Encode and store 3000x1500 video, assembled from a pair of side by side 1500x1500 image streams, at ~15fps.# Borrows callback techniques from stereo_preview.py example in Picamera2 github repository.from picamera2 import Picamera2, MappedArrayfrom picamera2.encoders import H264Encoderfrom picamera2.outputs import FfmpegOutputfrom libcamera import Transformimport timefps=15height=1500leftsize=(2*height,height) # define 2:1 format for left main streamrightsize=(height,height) # define 1:1 right main streamFrameTime=int(1000000/fps)# adopt a mixture of callback methods to repackage downsampled left image# into left half of stream, and also package 1:1 right image into the other half. def mergeviews(request):    request_2 = cam2_request    if request_2 is None:        return    request_2.acquire()        with MappedArray(request, "main") as m1, MappedArray(request_2, "main") as m2:        #fill left half of original left array with half-width downsampled left camera view        m1.array[:,:height] = m1.array[:,::2]        #fill right half of left array with 1:1 right camera view        m1.array[:,height:] = m2.array    request_2.release()        def save_request(request):    # Store most recent request for use by other camera    global cam2_request    if cam2_request is not None:        cam2_request.release()    request.acquire()    cam2_request = requestlcam = Picamera2(0)rcam = Picamera2(1)# select fastest full format sensor modemode = lcam.sensor_modes[5]# Configure both cameras to full format binned 2x2 mode and set the main stream to be 2:1 wide in left cam,# filled with the stretched central square zone of the sensor, right cam stream is set for equivalent square zone at 1:1.lconfig = lcam.create_video_configuration(sensor={"output_size": mode['size'], 'bit_depth':mode['bit_depth']},                                                  main={"format" :"RGB888","size":leftsize},                                                  controls={"ScalerCrop":(408,0,2464,2464),"FrameDurationLimits":(FrameTime,FrameTime)},                                                  transform=Transform(hflip=True,vflip=True),                                                  )rconfig = lcam.create_video_configuration(sensor={"output_size": mode['size'], 'bit_depth':mode['bit_depth']},                                                  main={"format" :"RGB888","size":rightsize},                                                  controls={"ScalerCrop":(408,0,2464,2464),"FrameDurationLimits":(FrameTime,FrameTime)},                                                  transform=Transform(hflip=True,vflip=True),                                                  )lcam.configure(lconfig)rcam.configure(rconfig)# Prepare to encode and output to an mp4 fileencoder= H264Encoder(10000000)output= FfmpegOutput("Test_left_right_combining.mp4")lcam.start()rcam.start()cam2_request = Nonercam.pre_callback = save_requestlcam.pre_callback = mergeviews# Record 20 seconds worthlcam.start_recording(encoder,output)time.sleep(20)      lcam.stop_recording()
If this works and the new synch patch is installed, where would the "--sync server" and "--sync client" tags be added in the code?

Statistics: Posted by MRV — Fri Oct 18, 2024 5:39 am



Viewing all articles
Browse latest Browse all 4906

Trending Articles