Video Encoding Issues

Hi everyone. I am trying to encode a video file, but I seem to get encoding issues. The output video comes out green!

To record the video I am using

gst-launch-1.0 v4l2src extra-controls=s,exposure=147434 device=/dev/video0 ! video/x-raw,format=BGRx ! filesink location = tester_2.mp4 -e

and then, to encode I use:

gst-launch-1.0 filesrc location=tester_2.mp4 ! videoparse ! videoconvert ! omxh265enc preset-level=0 temporal-tradeoff=0 ! qtmux ! filesink location = test.mp4 -e

I know it looks counter-intuitive to capture in BGRx, convert to YUV then convert back to be able to encode, but I am running some benchmarks, and need the intermediate step.

I am also able to capture video using v4l2-ctl with the following command:

v4l2-ctl -d /dev/video0 --set-fmt-video=width=1456,height=1088,pixelformat=VYUY --set-ctrl bypass_mode=0 --stream-mmap --stream-count=10 --stream-to=test.raw

but I get the same issue when attempting to encode the video.

For reference, when encoding, the output looks like this:

Is my encoding pipeline wrong?

Hi,
Please try the pipeline and check if you can see video preview:

$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=VYUY,width=1456,height=1088,framerate=30/1 ! videoconvert ! video/x-raw,format=NV12 ! nvvidconv ! nvoverlaysink

Hi @DaneLLL, unfortunatly this pipeline wonā€™t compile as V4L2 doesnā€™t support VYUY, as far as iā€™m aware to get VYUY I would need to run ā€œvideoconvertā€

P.S to check which formats were compatible with V4L2src I used:

gst-inspect-1.0 v4l2src

Hi,
Please check if the source can output YUYV or UYVY. Need to have the v4l2src-supported format or may not be able to run on Jetson platforms.

My Camera supports the following pixel formats:

 Index       : 1
    Type        : Video Capture
    Pixel Format: 'BX24'
    Name        : 32-bit XRGB 8-8-8-8
            Size: Discrete 1456x1088
                    Interval: Discrete 0.020s (49.688 fps)

    Index       : 2
    Type        : Video Capture
    Pixel Format: 'XR24'
    Name        : 32-bit BGRX 8-8-8-8
            Size: Discrete 1456x1088
                    Interval: Discrete 0.020s (49.688 fps)

    Index       : 3
    Type        : Video Capture
    Pixel Format: 'VYUY'
    Name        : VYUY 4:2:2
            Size: Discrete 1456x1088
                    Interval: Discrete 0.020s (49.688 fps)

However I know that VYUY is not supported by V4L2src.

One thing though, is I can source video from my camera using:

v4l2-ctl -d /dev/video0 --set-fmt-video=width=1456,height=1088,pixelformat=VYUY --set-ctrl bypass_mode=0 --stream-mmap --stream-count=10 --stream-to=test.raw

But Iā€™m not sure how to then encode the created file. Perhaps @DaneLLL you have an idea?

Hi,
You can try BGRx:

gst-launch-1.0 v4l2src ! video/x-raw,format=BGRx,width=1456,height=1088,framerate=50/1 ! videoconvert ! xvimagesink

check if you can launch the pipeline with the format.

It should be ok for some time, but for longer video recording, you may try to adjust framerate from 50/1 to 6211/125 according to your driver interval:

..., framerate=6211/125 ! ...
1 Like

Yes this pipeline does work, I have tested it numerous times. It would just be more convenient to obtain YUV directly

@DaneLLL Any updates?

I could try to encode the data from this pipeline:

v4l2-ctl -d /dev/video0 --set-fmt-video=width=1456,height=1088,pixelformat=VYUY --set-ctrl bypass_mode=0 --stream-mmap --stream-count=10 --stream-to=test.raw

How would you recommend I do so?

Best,

Alexis

Hi,
Since VYUY is not supported in v4l2src, you may consider to use jetson_multiemdia_api. Please try the sample in

/usr/src/jetson_multimedia_api/samples/12_camera_v4l2_cuda/

See if you can run it successfully and see video preview.

Hi @DaneLLL

Unfortunately that script did not work with my camera.

Hi,
VYUY is supported in the sample:

-f              Set output pixel format of video device (supports only YUYV/YVYU/UYVY/VYUY/GREY/MJPEG)

You may other USB cameras as comparison. Usually USB cameras output in YUYV or UYVY. We can run the sample with Logitech c930 and E-Con CU135. You may check if you can run the sample with either USB camera.