• DepthAI
  • Encode and preview mono stream

Hello,

Is it possible to encode and preview mono stream at the same time ? I've tried to do saomething like this:
(answered in another post)

but the monocamera don't have a 'preview' attribute

Also I'm a bit confused about what this code exactly does because when I change the fps the duration of the video saved changes and I want to record videos of fixed length but with different fps

thank you in advance

    ferrari19 but the monocamera don't have a 'preview' attribute

    It only has out so you have to use that. It outputs GRAY8 type frame which is compatible both with videoencoder as well as opencv.

    You have to set the decoder (ffmpeg) fps. Eg:

    • 10s recording with 30 fps = 300frames
      ----- decode it using -framerate 30 to get 10s video duration, or -framerate 15 to get 20s

    Hope it makes sense.

    Hello,

    Thank you for your answer. I've set a timer to only record for 10 seconds and I do -framerate 60 but I get a 4 seconds long video (and therefore the video is "acclerated"). It works perfectly fine with 25 fps but I don't understand why it doesn't work with 60 here's my code

    So I'm wondering if you know in 800p what's the maximum frame rate we can get for mp4 videos because from a certain frame rate the mp4 video is not the length of the recording and I don't understand why.

    Also when I try to preview the output link from my mono camera it doesn't work (the rgb preview link works fine)

    Thank you in advance

      Hi @ferrari19
      Are you setting the camera FPS? I can't see it in the code.

      ferrari19 Also when I try to preview the output link from my mono camera it doesn't work (the rgb preview link works fine)

      Code example please.

      Thanks
      Jaka

      Thank you for your quick answer

      I set the fps here

      to 60
      and here's the code to preview the mono left

      previewmono = outQ1.get()

      cv.imshow('preview', previewmono.getCvFrame)

      Thank you in advance

      Hi @ferrari19
      That's videoencoder FPS. Set the camera FPS directly using cam.setFps(fps). I think you are not reaching 60 fps on base camera stream, that's why the rest of the pipeline doesn't encode correctly. Could you check just the output of monocamera nodes to check if that might be the case?

      Thanks,
      Jaka

      Thank you! I had set the monLeft.setFps(60) and monoRight but it didn't change anything so I removed them. From what I read here the max frame rate is supposed to be 25 fps right ?

      https://docs.luxonis.com/projects/api/en/latest/samples/VideoEncoder/encoding_max_limit/#encoding-max-limit

      I think indeed I'm not reaching 60 fps in base camera cause when I tried to get videos with the SDK record

      from depthai_sdk import OakCamera, RecordType

      with OakCamera() as oak:   

      #color = oak.create_camera('color', resolution='1080P', fps=20, encode='H265')   

      left = oak.create_camera('left', resolution='800p', fps=60, encode='H265')   

      right = oak.create_camera('right', resolution='800p', fps=60, encode='H265')
          # Synchronize & save all (encoded) streams   

      oak.record([left.out.encoded, right.out.encoded], './', RecordType.VIDEO)   

      oak.visualize([left.out.camera], scale=2/3, fps=True)
          oak.start(blocking=True)

      when I set the fps to 60 it didn't go over 30 fps in the visualization. The thing is I'm just trying to get mp4 videos with max fps and max resolution with oak-d camera, so do you know what's the max frame rate I can get with POE

      Thank you in advance

      Hi @ferrari19
      Visualizer also won't work on 60+ since you are limited by opencv imshow(). I was able to get around 55 FPS while using MJPEG encoding on 800p streams. Would that suffice?

      Thanks,
      Jaka

      yes that would be perfect but when I try with 50 fps I get "accelerated" mp4 videos do you have any idea why or what I'm doing wrong (it's the same code I sent before except I added setFps(60) for both mono cameras) ?

      Hi @ferrari19
      Likely the encoder is still unable to keep up with the cameras. The speed might also be lowered as you are sending the RGB stream, which adds to the additional bandwidth requirements.

      Thanks,
      Jaka

      Thank you! Also, I was wondering if it's possible to skip the first ~50 frames when encoding to remove auto-exposure frames.

      Thank you in advnace