How capture video from camera on Jetson nano in h264?

Hi, I try make video recorder with Jetson nano. I tried capture video use command-line:

gst-launch-1.0 nvarguscamerasrc num-buffers=1200 gainrange="1 1" ispdigitalgainrange="2 2" ! 'video/x-raw(memory:NVMM),width=1280, height=720, framerate=120/1, format=NV12' ! omxh264enc ! qtmux ! filesink location=test.mp4 -e

Everything works, but I can’t control start\stop record.

So,I try use OpenCv to control record from camera, use this sample:

def gstreamer():
    return ('nvarguscamerasrc gainrange="1 1" ispdigitalgainrange="2 2" ! '
            'video/x-raw(memory:NVMM), '
            'width=1280, height=720, '
            'format=(string)NV12, framerate=120/1 ! '
            'nvvidconv flip-method=0 ! '
            'video/x-raw, width=1280, height=720, format=(string)BGRx ! '
            'videoconvert ! '
            'video/x-raw, format=(string)BGR ! appsink')


cap = cv2.VideoCapture(gstreamer(), cv2.CAP_GSTREAMER)

fourcc = cv2.VideoWriter_fourcc(*"X264")
writer = cv2.VideoWriter("out/{}".format(name), fourcc, 30, (1280, 720), True)
if cap.isOpened():
    for i in range(120):
        ret_val, img = cap.read()
        writer.write(img)
writer.release()
cap.release()

I can start\stop recoding, but X264 codec in OpenCV work slow on Jetson, I can take only 10 FPS.

How I can write stream from command line sample already code in h264 to file?

Hi,
Please try C/C++ programming to launch a gstreamer pipeline. There is a sample in below post:
https://devtalk.nvidia.com/default/topic/1015571/jetson-tx2/what-is-maximum-video-encoding-resolution-in-pixels-/post/5253760/#5253760

You may also want to look at sample 10_camera_recording.

https://docs.nvidia.com/jetson/l4t-multimedia/l4t_mm_camera_recording.html

Hi dimaretunskiy,

I recommend using our gstd (Gstreamer Daemon) tool, it is open source. gstd allows fine-grained control over gstreamer pipelines, including the states (null, ready, paused and playing). This is something that you can’t do with gst-launch. Here is a basic example for .mp4 recording: https://developer.ridgerun.com/wiki/index.php?title=GStreamer_Daemon_-_MP4_Video_Recording