Gstreamer fails to save to file

I am looking to use gstreamer to create a pipeline which takes input from 6 cameras. But I’m first taking it slow, and trying out one camera instead. Given the following command:

gst-launch-1.0 nvarguscamerasrc sensor-mode=0 ! "video/x-raw(memory:NVMM), width=(int)5328, height=(int)4512, format=(string)NV12, framerate=(fraction)15/1" ! nvvidconv ! "video/x-raw(memory:NVMM), width=(int)4096, height=(int)4096" ! filesink location=filename.mp4 -e

I haven’t been able to get it to save to file. It does display the output correctly if I ask it to display on screen with nvoverlaysink -e instead.

I would also prefer it if the final command contains the h264/h265 compression, but it might end up needing more things introduced in the pipeline in the meantime (such as cropping/stiching multiple videos into one tall video).

Hi @mircea.claudiu.01

You are not seeing anything in your video because you are missing the muxer element to get a valid MP4.

You could try the following pipelines to get the h264 and h265 encoded videos:

H264:

gst-launch-1.0 nvarguscamerasrc sensor-mode=0 ! "video/x-raw(memory:NVMM), width=(int)5328, height=(int)4512, format=(string)NV12, framerate=(fraction)15/1" ! nvvidconv ! "video/x-raw(memory:NVMM), width=(int)4096, height=(int)4096" ! nvv4l2h264enc ! h264parse ! mp4mux ! filesink location=filename.mp4 -e

H265:

gst-launch-1.0 nvarguscamerasrc sensor-mode=0 ! "video/x-raw(memory:NVMM), width=(int)5328, height=(int)4512, format=(string)NV12, framerate=(fraction)15/1" ! nvvidconv ! "video/x-raw(memory:NVMM), width=(int)4096, height=(int)4096" ! nvv4l2h265enc ! h265parse ! mp4mux ! filesink location=filename.mp4 -e

Regards,
Jimena Salas

Hello @JimenaSalas

All of the examples I had seen involved qtmux, and after reading, it was for .mov, so I thought removing it would be beneficial.

Anyway, I have just tried the first example, and it still does not output anything. It creates the file, but nothing comes out.

In the h265 one, it even comes up with an error, but has created a file that gets detected as a proper mp4 file. Only issue is that it came up with an error in gstreamer while recording.

===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 8 
NVMEDIA: H265 : Profile : 1 
tvmrVideoEncoderBitsAvailable_MSENC: ucode ERROR = 96 
NvVideoEncTransferOutputBufferToBlock: DoWork failed line# 667 
NvVideoEnc: NvVideoEncTransferOutputBufferToBlock TransferBufferToBlock failed Line=678

The video is unplayable, by the way.

So, both errors ended up being caused by the same thing: the output file is marked as .mp4, and for some reason, nvv4l2h264enc (and h265enc) refuses to work. The problem was then fixed by marking the output file as .h264 or .h265, following this post: https://developer.ridgerun.com/wiki/index.php?title=JetsonTX2/GStreamer/Jetpack4.2%2B/Encoding#H264_Encoding_from_Camera_2.

Also, as a sidenote, the width of the video has to be within the accepted bounds of the encoder. I am not sure of the exact size, but the furthest that I could push it (while staying within my sensor module’s bounds) was 4064 pixels wide.