Multiple Decodes/Encodes - Multiple Decodes/Encodes - 3.0 English - PG447

H.264/H.265/JPEG Video Codec Unit 2 (VCU2) Solutions LogiCORE IP Product Guide (PG447)

Document ID
PG447
Release Date
2026-03-06
Version
3.0 English

Encode and decode input YUV into two streams by using two different encoder and two different decoder elements.

V4l2 > AVC encode > AVC Decode > HEVC encode > fakesink

(AVC and HEVC encoding in single pipeline)

gst-launch-1.0 -v v4l2src device=/dev/video0 io-mode=4 num-buffers=300 ! video/x-raw, width=3840, height=2160, format=NV12, framerate=30/1 ! tee name=t ! queue max-size-bytes=0 ! omxh264enc target-bitrate=25000 control-rate=constant num-slices=8 gop-mode=basic gop-length=30 prefetch-buffer=TRUE ! video/x-h264, profile=high, alignment=au ! queue ! omxh264dec ! queue max-size-bytes=0 ! omxh265enc target-bitrate=25000 control-rate=constant num-slices=8 gop-mode=basic gop-length=30 prefetch-buffer=TRUE ! video/x-h265, profile=main, alignment=au ! queue max-size-bytes=0 ! fpsdisplaysink name=fpssink text-overlay=false video-sink="fakesink sync=true" sync=true -v &
V4L2 > AVC encode > kmssink V4l2 > HEVC encode > kmssink

(AVC and HEVC encoding and decoding in a single pipeline)

gst-launch-1.0 -v v4l2src device=/dev/video0 io-mode=4 num-buffers=800 ! video/x-raw, width=3840, height=2160, format=NV12, framerate=30/1 ! omxh264enc target-bitrate=25000 control-rate=constant num-slices=8 gop-mode=basic gop-length=30 prefetch-buffer=TRUE ! video/x-h264, profile=high, alignment=au ! queue ! omxh264dec ! queue max-size-bytes=0 ! fpsdisplaysink name=fpssink1 text-overlay=false video-sink="kmssink bus-id="b0080000.v_mix" hold-extra-sample=TRUE plane-id=33 render-rectangle=<0,0,1920,2160>" sync=true v4l2src device=/dev/video4 io-mode=4 num-buffers=800 ! video/x-raw, width=3840, height=2160, format=NV12, framerate=30/1 ! omxh265enc target-bitrate=25000 control-rate=constant num-slices=8 gop-mode=basic gop-length=30 prefetch-buffer=TRUE ! video/x-h265, profile=main, alignment=au ! queue ! omxh265dec ! queue max-size-bytes=0 ! fpsdisplaysink name=fpssink2 text-overlay=false video-sink="kmssink bus-id="b0080000.v_mix" hold-extra-sample=TRUE plane-id=34 render-rectangle=<1920,0,1920,2160>" sync=true -v &

In the above GStreamer pipeline, the mixer IP is used to overlay plane 33 and 34 on to the primary display plane. Plane 33 is displayed at 0,0 with a width of 1920 and height of 2160. Plane 34 is displayed at 1920, 0 with a width of 1920 and height of 2160. The output resembles the following figure.

Figure 1. Multi-Stream to Mixer
Decode multiple videos simultaneously:
Note: This gst-launch-1.0 command uses a tee to send data to four decoder instances. Alternatively, a gst-launch-1.0 command can be done for each decode instance.
gst-launch-1.0 filesrc location=in.mp4 ! qtdemux ! h265parse ! tee name=t \
t. ! queue ! omxh265dec ! queue max-size-bytes=0 ! filesink location=out1.yuv \
t. ! queue ! omxh265dec ! queue max-size-bytes=0 ! filesink location=out2.yuv \
t. ! queue ! omxh265dec ! queue max-size-bytes=0 ! filesink location=out3.yuv \ 
t. ! queue ! omxh265dec ! queue max-size-bytes=0 ! filesink location=out4.yuv
Encode multiple streams simultaneously
Note: This gst-launch-1.0 command uses a tee to feed the same input to different encoders. Alternatively, multiple gst-launch-1.0 commands could be done and feed different inputs.
gst-launch-1.0 filesrc location=in.yuv ! rawvideoparse width=1920 height=1080 format=nv12 framerate=30/1 ! tee name=t \
t. ! queue ! omxh264enc control-rate=2 target-bitrate=8000 ! video/x-h264, profile=high ! filesink location=out0.h264 \
t. ! queue ! omxh264enc control-rate=2 target-bitrate=8000 ! video/x-h264, profile=high ! filesink location=out1.h264 \
t. ! queue ! omxh264enc control-rate=2 target-bitrate=8000 ! video/x-h264, profile=high ! filesink location=out2.h264 \
t. ! queue ! omxh264enc control-rate=2 target-bitrate=8000 ! video/x-h264, profile=high ! filesink location=out3.h264 \
t. ! queue ! omxh264enc control-rate=2 target-bitrate=8000 ! video/x-h264, profile=high ! filesink location=out4.h264 \
t. ! queue ! omxh264enc control-rate=2 target-bitrate=8000 ! video/x-h264, profile=high ! filesink location=out5.h264 \
t. ! queue ! omxh264enc control-rate=2 target-bitrate=8000 ! video/x-h264, profile=high ! filesink location=out6.h264 
t. ! queue ! omxh264enc control-rate=2 target-bitrate=8000 ! video/x-h264, profile=high ! filesink location=out7.h264