Command for merging audio and video in Gstreamer

Hello, I tried to make an .mkv format video recording with audio using the following command on the AGX Xavier dev kit

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw, width=3840, height=2160, framerate=30/1, format=UYVY' ! nvvidconv ! 'video/x-raw(memory:NVMM), format=I420,  format=(string)I420, width=(int)3840,height=(int)2160' ! queue ! omxh264enc bitrate=32000000 ! h264parse ! matroskamux name=mux ! filesink location=file1.mkv -e alsasrc device="hw:1,1" ! 'audio/x-raw, format=(string)S16LE, layout=(string)interleaved, channels (int)2, channel-mask=(bitmask)0x0000000000000003, rate=(int)48000' ! queue ! audioconvert ! lamemp3enc ! mux.

There is video, but NO audio . However, there is a static noise in the background.

The working command I use for audio saving is

gst-launch-1.0 alsasrc num-buffers=1000 device="hw:1,1" ! audio/x-raw,format=S16LE ! wavenc ! filesink location = a.wav

The working command I use for video saving

gst-launch-1.0 v4l2src device=/dev/video0 ! "video/x-raw, format=(string)UYVY, width=(int)3840, height=(int)2160" ! nvvidconv ! "video/x-raw(memory:NVMM), format=(string)I420, width=(int)3840, height=(int)2160" ! omxh264enc ! matroskamux ! queue ! filesink location=<filename1.mkv>

So I would like to combine these commands for on-device saving.

Could someone give me the correct command for saving video and audio together in an unique file through the use of Gstreamer?

The output file from filesink can be .mp4, .ogg, .mkv, or whatever as long as the video has audio with it.

Thank you!

A general combination is H264+AAC. You may try


Additionally to the info provided by DaneLLL, you could take the following pipeline as reference for what you are trying to achieve.

gst-launch-1.0 -e videotestsrc is-live=true ! x264enc ! mp4mux name=mux ! filesink location="video_and_audio.mp4"  audiotestsrc ! lamemp3enc ! mux.