AM62Ax Sitara SoC has Hardware accelerator that enables users to encode and decode both HEVC/H.265 and H.264/AVC video formats.
The open source GStreamer plugins provide elements for GStreamer pipelines that enable the use of hardware-accelerated video encoding/decoding through the V4L2 GStreamer plugin.
Below is a list of GStreamer plugins that utilize the hardware-accelerated video decoding/encoding in the AM62Ax.
-
ENCODER
- v4l2h264enc
- v4l2h265enc
-
DECODER
- v4l2h264dec
- v4l2h265dec
Input formats that Encoders support are:
- V4L2_PIX_FMT_YUV420
- V4L2_PIX_FMT_NV12
- V4L2_PIX_FMT_NV21
- V4L2_PIX_FMT_YUV420M
- V4L2_PIX_FMT_NV12M
- V4L2_PIX_FMT_NV21M
The V4L2 encoder/decoder driver supports the following bitstream formats:
- V4L2_PIX_FMT_H264
- V4L2_PIX_FMT_HEVC
Here are a few use-cases:
File Playback - Encode:
H.264 encode:
gst-launch-1.0 filesrc location=/<path_to_file> ! rawvideoparse width=1920 height=1080 format=i420 framerate=30/1 ! v4l2h264enc ! filesink location=/<path_to_file> sync=true H.265 encode:
gst-launch-1.0 filesrc location=/<path_to_file> ! rawvideoparse width=1920 height=1080 format=i420 framerate=30/1 ! v4l2h265enc ! filesink location=/<path_to_file> sync=true
File Playback - Decode:
H.264 decode:
gst-launch-1.0 filesrc location=/<path_to_file> ! matroskademux ! h264parse ! queue ! v4l2h264dec ! filesink location=/<path_to_file> H.265 decode:
gst-launch-1.0 filesrc location=/<path_to_file> ! matroskademux ! h265parse ! queue ! v4l2h265dec ! filesink location=/<path_to_file>
Video Playback to Display:
gst-launch-1.0 filesrc location=./bbb_1080p60_30s.h264 ! h264parse ! v4l2h264dec capture-io-mode=dmabuf ! kmssink driver-name=tidss -v
Audio/Video file playback (h264/aac muxed file as example):
gst-launch-1.0 filesrc location=bbb_1080p_aac.mp4 ! qtdemux name=demux demux.video_0 ! h264parse ! v4l2h264dec capture-io-mode=dmabuf ! queue ! kmssink driver-name=tidss demux.audio_0 ! queue ! faad ! audioconvert ! audioresample ! audio/x-raw, channels=2, rate=48000 ! autoaudiosink
Transcode use-case (h264->h265 conversion as example):
gst-launch-1.0 filesrc location=./sample_file.264 ! h264parse ! v4l2h264dec capture-io-mode=4 ! v4l2h265enc output-io-mode=5 ! filesink location=./output.265
Video Streaming:
Server (imx219 rawcamera->isp->encode->streamout):
gst-launch-1.0 v4l2src device=/dev/video2 io-mode=dmabuf ! video/x-bayer,width=1920,height=1080, framerate=30/1, format=bggr ! tiovxisp sensor-name=SENSOR_SONY_IMX219_RPI dcc-isp-file=/opt/imaging/imx219/dcc_viss.bin sink_0::dcc-2a-file=/opt/imaging/imx219/dcc_2a.bin sink_0::device=/dev/v4l-subdev2 ! video/x-raw,format=NV12 ! v4l2h264enc output-io-mode=dmabuf-import extra-controls="controls,h264_i_frame_period=60" ! rtph264pay ! udpsink port=5000 host=<ip_address>
Client (streaming->decode->display):
gst-launch-1.0 -v udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtpjitterbuffer latency=50 ! rtph264depay ! h264parse ! v4l2h264dec capture-io-mode=dmabuf ! queue ! fpsdisplaysink text-overlay=false name=fpssink video-sink="kmssink driver-name=tidss sync=true show-preroll-frame=false" sync=true -v
Video Capture->Multiscaler (4 different resolutions)->Encode
gst-launch-1.0 -v v4l2src device=/dev/video2 io-mode=dmabuf-import num-buffers=500 ! \
video/x-bayer, width=1920, height=1080, framerate=60/1, format=rggb10 ! \
tiovxisp sink_0::device=/dev/v4l-subdev2 sensor-name="SENSOR_SONY_IMX219_RPI" dcc-isp-file=/opt/imaging/imx219/dcc_viss_10b.bin sink_0::dcc-2a-file=/opt/imaging/imx219/dcc_2a_10b.bin format-msb=9 ! \
video/x-raw, format=NV12, width=1920, height=1080, framerate=30/1 ! \
tiovxmultiscaler name=msc \
msc. ! queue ! video/x-raw, format=NV12, width=640, height=480, framerate=30/1 ! v4l2h264enc ! filesink location=480.264 \
msc. ! queue ! video/x-raw, format=NV12, width=1920, height=1080, framerate=30/1 ! v4l2h264enc ! filesink location=1080.264 \
msc. ! queue ! video/x-raw, format=NV12, width=1280, height=720, framerate=30/1 ! v4l2h264enc ! filesink location=720.264 \
msc. ! queue ! video/x-raw, format=NV12, width=480, height=320, framerate=30/1 ! v4l2h264enc ! filesink location=320.264