Use the following pipelines to record video from an input source to the required file format.
- To record only the video
stream:
gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! \ video/x-raw,format=NV12,width=3840,height=2160,framerate=60/1 ! \ omxh265enc qp-mode=auto gop-mode=basic gop-length=60 b-frames=0 \ target-bitrate=60000 num-slices=8 control-rate=constant prefetch-buffer=true \ low-bandwidth=false filler-data=true cpb-size=1000 initial-delay=500 ! \ queue ! video/x-h265, profile=main, alignment=au ! mpegtsmux alignment=7 name=mux ! \ filesink location="/run/media/sda/test.ts"This example shows that the live source device link is present under the
/devdirectory. Encoded video format is H265 and color format is NV12. Video stream resolution is 4k and 60fps. The record filetest.tsis present in SATA drive in TS file format.Note:- For input source with 1080p@60 resolution, replace width and height with 1920 and 1080 respectively. Frame rate can also be changed to 30.
- To encode input stream into H264 video format, replace h265 in the above pipeline with h264.
- To record both the video and audio stream:
The following pipeline can be used to record video with audio from an input source to the required file format.
gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! \ video/x-raw, format=NV12, width=3840, height=2160, framerate=60/1 ! \ omxh265enc qp-mode=auto gop-mode=basic gop-length=60 b-frames=0 \ target-bitrate=60000 num-slices=8 control-rate=constant prefetch-buffer=true \ low-bandwidth=false filler-data=true cpb-size=1000 initial-delay=500 ! \ video/x-h265, profile=main, alignment=au ! queue ! mux. alsasrc device=hw:2,1 ! \ audio/x-raw, format=S24_32LE, rate=48000, channels=2 ! queue ! \ audioconvert ! audioresample ! faac ! aacparse ! mpegtsmux name=mux ! \ filesink location="/run/media/sda/test.ts"In this example, video and audio can be encoded using a single gstreamer pipeline to record into a single file. Encoded audio stream is AAC. Audio capture device is hw:2,1 and record file
test.tsis present in SATA. For video encoding, the pipeline remains the same as the previous example.