how to control on-board camera such as saving images and videos

I want to use the camera embedded on NVIDIA jetson TX2 to save images and videos for further usage. Now I can only start it using the command gst-launch-1.0, but I don’t know how to control it to save images or videos. Could anyone who knows tell me. Thanks!

You may use gstreamer plugin filesink. For example, saving 100 frames in I420 format and playing from file :

gst-launch-1.0 -e nvcamerasrc num-buffers=100 ! nvvidconv ! 'video/x-raw, format=I420, width=640, height=480, framerate=30/1' ! filesink location=./test.i420

gst-launch-1.0 -e filesrc location=./test.i420 ! videoparse format=2 width=640 height=480 framerate=30/1 ! xvimagesink

Note that it may fill your disk quickly, so it is much safer to record on an external disk or SD Card.

For image/video capture on a keypress, in interactive mode, you may also use

nvgstcapture -m 2 -k 2 -w 10

then press “1” and “0” to start and stop recording, or “2” to take snapshot.
For video+audio capture to file you may refer to the thread.
However, to capture a long time recording you may like to mount Host PC hdd with :

sshfs [user@]hostname:[directory] mountpoint/
cd mountpoint
gst-launch-1.0 -e alsasrc ! voaacenc ! queue ! qtmux name=mux ! filesink location=a.mp4    nvcamerasrc ! omxh264enc ! queue ! mux.

The above will write the resulting file to the disk drive of a Host PC. However, the recording will be available under local folder at Jetson, as long as the hdd of Host PC is sshfs-mounted.
Reference

hi, Andrey1984

Thank you for your reply, I tried the command you pointed out, but once the camera was opened, the terminal and other folders would be sheltered, and I couldn’t do any other operations because the big video window couldn’t be moved but stood in the middle of the desktop. Also, I don’t know how to close the video window because there is no close button at all. Have you encountered the same issue?

I think if you pass to terminal cntrl+c it will close the window;
if you pass 1 it will start recording
if you pass 0 it will stop recording;
However, you can change resolution of the video output and make the window smaller or some overlapping settings might be find in documentation.
I used terminal in a way it is seen aside from the video output of the camera. That allowed to pass keypress to the terminal, though partially covered with video.
You can just click at sidebar to the terminal make it active and pass commands, in my opinion.