Overview
v4l2h265enc is a hardware-accelerated video encoder that uses the Video4Linux2 (V4L2) stateful encoder API to offload H.265 (HEVC) video encoding to the Qualcomm Video Processing Unit (VPU).
This plugin is provided and maintained by the GStreamer community. This document focuses on its usage in conjunction with Qualcomm-specific QIM SDK GStreamer plugins, along with relevant use cases and internal architectural considerations.
v4l2h265enc is typically used in encoding pipelines for:
- Camera capture and local recording with higher compression efficiency than H.264
- Video transcoding (e.g., H.264 → H.265)
- Live streaming (RTSP, HLS, UDP)
- 4K and HDR10 content encoding
- Multi-stream simultaneous encoding
h265parse, mp4mux).
Example Pipeline

1
Download Required Files
2
Copy files to device
3
Connect to device
4
Set environment variables
Run below command on your device
5
Run the pipeline
Key Responsibilities
v4l2h265enc is responsible for:
- Hardware acceleration — offloads H.265/HEVC encoding to the dedicated VPU
- V4L2 state management — manages the V4L2 stateful encoder state machine (device open, buffer allocation, stream on/off)
- Buffer I/O management — handles buffer exchange between GStreamer and the V4L2 driver using DMABuf, MMAP, or UserPtr modes
- Format negotiation — negotiates raw input formats supported by the hardware, including UBWC-compressed formats for reduced memory bandwidth
- Profile and level selection — negotiates H.265 profile and level with downstream elements based on hardware capabilities probed at registration time
- Encoder parameter control — supports runtime configuration of encoding parameters (bitrate, GOP size, QP values, etc.) via the
extra-controlsproperty - Multi-stream support — supports multiple concurrent encoder instances (subject to hardware resource limits)
Hierarchy
GObjectGstObject
GstElement
GstVideoEncoder
GstV4l2VideoEnc
v4l2h265enc
Pad Templates
sink
src
The exact set of profiles and levels reported depends on what the underlying V4L2 driver enumerates via
V4L2_CID_MPEG_VIDEO_HEVC_PROFILE and V4L2_CID_MPEG_VIDEO_HEVC_LEVEL.Element Properties
I/O Mode Values
Bothcapture-io-mode and output-io-mode accept the same GstV4l2IOMode enumeration:
Internal Architecture
v4l2h265enc operates using two V4L2 queue objects internally:
- Output queue (
V4L2_BUF_TYPE_VIDEO_OUTPUT) — receives raw video frame buffers from upstream - Capture queue (
V4L2_BUF_TYPE_VIDEO_CAPTURE) — produces encoded H.265 bitstream buffers for downstream

State Transitions
Memory and Buffer Management
DMABuf Usage
For zero-copy pipelines where raw frames originate from a hardware source (camera, GPU, or hardware decoder):- Set
output-io-mode=dmabuf-import(value5) to import DMABuf handles from upstream directly into the V4L2 output queue without CPU copies - Set
capture-io-mode=dmabuf(value4) to export encoded output as DMABuf file descriptors for downstream elements
Alignment Requirements
Input buffers follow Qualcomm hardware alignment requirements (e.g., 128-byte stride alignment). UBWC-compressed input formats (NV12_Q08C, NV12_Q10LE32C) are supported for reduced memory bandwidth when the upstream source produces UBWC output.
Encoder Parameter Control
Encoding parameters are configured via theextra-controls property using V4L2 control IDs. Common parameters include:
Example:
Drain and Flush
- Drain — sends
V4L2_ENC_CMD_STOPviaVIDIOC_ENCODER_CMD; waits for all remaining encoded frames to be produced - Flush — stops both queues, resets buffer pools, and restarts streaming; used during seek operations
Usage
Ensure you have followed the prerequisites before continuing
Record Camera to H.265 MP4 File
Captures raw video from a camera source, encodes to H.265 with DMABuf zero-copy, and muxes into an MP4 container.
Transcode H.264 to H.265
Decodes an H.264 stream from an MP4 file using the hardware decoder and re-encodes to H.265 using the hardware encoder. DMABuf is used for zero-copy transfer between decoder and encoder.
Four-Stream Simultaneous Encoding
Encodes four concurrent H.265 streams from four sources using four independent hardware encoder instances.

