Save video as .avi in real time on TX2

Hi,I’d like to save video from a usb camera as a .avi file on TX2.
I try to use gsteramer but I can only sava a .H264 file.
So,I want to know how can I bulid the pipeline in order to save avi.
This is a application which is writen by C/C++,so maybe we can not use the commandline directly in my program.

Please use avimux

Thanks for your answer,but my video just contain video without audio .Maybe the method is not so suit.

It works in video only.

$ gst-launch-1.0 nvcamerasrc num-buffers=150 ! omxh264enc ! avimux ! filesink location=a.avi

If you need mp4, it is qtmux. If you need mkv, it is matroskamux. FYI.

Hi DaneLLL,
I have solved my problem.There was a bug in the code.
Thanks for your kind help.
The pipeline your offered me was just right.

I also come up with a probllem about how to set tx2 usb as device mode and I found you have some experience on that.Will you offer me furthur more information:

Suggest you try filesink. It seems something wrong in your appsink. You should perform memcpy() in every pull sample. Also if you want to save into multiple files, you should use multifilesink.