Gstreamer how to save raw video and play back

Hi
I use the code to save raw video as a file

gst-launch-1.0 -e v4l2src device=/dev/video0 \
        ! "video/x-raw, format=(string)UYVY, width=(int)2592, height=(int)1944,framerate=(fraction)28/1" \
        ! filesink location=video-raw-file.UYVY

and play back:

gst-launch-1.0 filesrc location=video-raw-file.UYVY \
        ! videoparse format=5 width=2592 height=1944 framerate=28/1 \
        ! xvimagesink

When I changed the videoo source from v4l2src to nvv4l2camerasrc as below:

gst-launch-1.0 -e nvv4l2camerasrc device=/dev/video0 \
        ! "video/x-raw(memory:NVMM), format=(string)UYVY, width=(int)2592, height=(int)1944,framerate=(fraction)28/1" \
        ! filesink location=video-raw-file.UYVY

run save video code has no any warning message.
But, when play back using the same play back code resulted following error message:

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstVideoParse:videoparse0/GstRawVideoParse:inner_rawvideoparse: No valid frames found before end of stream
Additional debug info:
gstbaseparse.c(3603): gst_base_parse_loop (): /GstPipeline:pipeline0/GstVideoParse:videoparse0/GstRawVideoParse:inner_rawvideoparse
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

I don’t know what is the problem of my save video code or the play back code as I am new to gstreamer.

Would you please help me to correct it. Thanks

filesink is a cpu only plugin and cannot use NVVM memory as outputted by nvv4vl2camerasrc.
You would have to insert nvvideoconvert in between for copying from NVMM to standard memory:

gst-launch-1.0 -e nvv4l2camerasrc device=/dev/video0 ! 'video/x-raw(memory:NVMM), format=UYVY, width=2592, height=1944,framerate=28/1' ! nvvideoconvert ! filesink location=video-raw-file.UYVY

Be aware however that raw frames result in huge size per frame, so save into external storage, not to your root filesystem, if filled up it would make your system unsable.

Thank you for kind reply.
I tried your code. It does not work.

  1. Insert “nvvideoconvert” , erroneous pipeline: no element “nvvideoconvert”
  2. Insert “nvvidconv”, can’t play back using my play back code as above. The error message is the same as before.
  3. Insert “videoconvert”, it is the same as “nvvidconv

Any suggestion?
Thanks

Sorry for previous command.
It would work with nvvidconv, but you would have to specify standard memory as its output:

gst-launch-1.0 -e nvv4l2camerasrc device=/dev/video0 ! 'video/x-raw(memory:NVMM), format=UYVY, width=2592, height=1944,framerate=28/1' ! nvvidconv ! video/x-raw, format=UYVY ! filesink location=video-raw-file.UYVY

Thanks for kind reply.
The code can save the video as a file.
The recorded time is 29.4946 S, but play back is only 2.9211 S. I don’t know what’s wrong with it, frame lost or something else?

Hi,
Saving raw UYVY frames take heavy load and may not be able to reach source rate. Also timestamp information is not included. Suggest you record the frames into mp4 or mkv.

Hi DaneLLL,
Thank you very much for your kind suggestion.
I have noticed that to save raw UYVY frames, the write speed requirement for Micro SD card is very high. Would you please let me know what is the max write speed supported from Jetson Nano and which type of high speed SD card supported by Jetson Nano as well (SD XC V30, V60 or V90?). It seems that Jetson Nano does not support UHS type micro SD card, is it?
On the other hand, would you please give me your suggestion which video format (MP4 or MKV) and which encode mode (H264, H265, VP8) can get better video (no audio) quality and the best still image from the recorded video?
What is the max micro SD card storage size supported by Jetson Nano?
Thanks

Hi,
For SDIO speed, please take a look at
https://developer.nvidia.com/embedded/dlc/jetson-nano-system-module-datasheet

For video quality, there are encoder properties you can adjust and check. You may refer to