V4ctl stream-to slows down the frame rate

Hi,

I am using a Jetson Nano (JP4.4) and a raspberry pi v2 camera (IMX219) and currently recording RAW videos at 120fps using the v4ctl library. I am powering the device using a microusb cable (5V 2.1A). When I just stream images using this command,

v4l2-ctl -d /dev/video0 -csensor_mode=4 --set-fmt-video=width=1280,height=720,pixelformat=RG10 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=600

I get the following output:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 122.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 121.50 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 121.33 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 121.25 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 121.40 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 121.33 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 121.28 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 121.25 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 121.33 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 121.30 fps

i.e it is stable at ~120fps.

When I try to save the raw file using this command

v4l2-ctl -d /dev/video0 -csensor_mode=4 --set-fmt-video=width=1280,height=720,pixelformat=RG10 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=10000 --stream-to=FILE.raw

i get this output:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 119.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 109.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 90.33 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 79.50 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 69.96 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 66.50 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 62.10 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 59.05 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 56.65 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<^X<<< 54.74 fps

So the frame rate seems to drop very quickly and it slows down.

I thought that maybe 120fps might be an issue so I changed the framerate to 60fps by modifying the csensor_mode using this command:

v4l2-ctl -d /dev/video0 -csensor_mode=3 --set-fmt-video=width=1280,height=720,pixelformat=RG10 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=600

and I got stable 60fps streaming. When I tried to save the file, I noticed this

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 60.39 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 59.90 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 60.13 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 60.25 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 49.04 fps
<<<<<<<<<<<<<< 49.50 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 51.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 52.18 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 52.00 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 51.09 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 49.95 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 48.87 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 48.03 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 47.28 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 46.66 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 46.12 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 45.62 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 45.17 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 44.84 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 44.50 fps

So even at 60fps, it seems to be slowing down the framerate when it drops.

I was wondering:

[1] why is there such a slow down in fps when saving the file?
[2] Is there some other way to save this raw output so that I can have a stable frame rate at 120fps? I only need to acquire 5-10 seconds of video data.

Hi @msingh44,

It looks like there is some kind of limitation from the v4l2-ctl tool when saving frames. Something like the process of saving the image is made in the same thread as the capture one.

I think of two options that you can try to workaround this:

  1. Use gstreamer with the v4l2src element to dequeue the frames, sadly, as I read you use imx219 with RAW10, which I believe v4l2src on gstreamer 1.14.5 doesn’t support. But we have created instructions in the past in order to apply a patch to enable this support: Compile GStreamer on NVIDIA Jetson TX1, TX2, and Nano - RidgeRun Developer Wiki. You can check them, there are complete instructions to build gstreamer 1.14.5 plugins and an example to capture the frames as you want as well. Reach me out if there are any questions for this. With gstreamer you will probably use a pipeline like

gst-launch-1.0 -vvv v4l2src num-buffers=10000 ! “video/x-bayer,width=1920,height=1080 format=bggr” ! filesink location=“test.raw”

  1. Modify a similar app like v4l2-ctl as this post explains: V4l2-ctl not respecting frame_rate control, unlike Gstreamer on IMX477 + Nano 2GB - #15 by ShaneCCC

Regards,
Roberto Gutierrez,
Embedded SW Engineer at RidgeRun
Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com/

Hi @robertogs2 ,

Thank you for your response. I read through your instructions on how to compile GStreamer for the Jetson Nano. I had a question about the process.

[1] Do I need to complete steps 1-6 of the “Steps to compile GStreamer on Jetson TX1, TX2, and Nano” first or can I just start from the section " Steps to patch GStreamer to support RAW10" ?

Hi,

You will need to complete those first steps, you can try it out with only the gst-plugins-good compilation, but I don’t really know if the compilation will fail for missing build artifacts from the previous packages. I think you can forget about the bad and ugly plugins packages, those shouldn’t be a dependency for good package.

Hope that helps

Regards,
Roberto

Hi Roberto

I’ve tried to implement a simple c script using the v4l2 api to acquire a single image from the raspberry pi v2 camera but I am running into a couple of issues and was wondering if you could help me out. I’ve made a post about the issue here – Acquiring image using v4ctl api

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.