Hardware x265 encoding using gstreamer

Hi,

is it possible to use hardware-based x265 encoding using gstreamer? It seems this that the my hardware (Xperia 10 III) supports it, since Android apps (Larix broadcaster) can do it, without much CPU usage. Media Codec Info lists OMX.qcom.video.encoder.hevc and c2.android.hevc.encoder.

Peeking around with gst-inspect-1.0, it seems that droidvenc and droidvdec provide encoders and decoders based on the Android HAL. The decoder seems to support video/x-h264, video/x-h265 and video/x-vp9, while the encoder only supports video/x-h264:

[defaultuser@Xperia10III ~]$ /usr/bin/gst-inspect-1.0 droidvenc
...
  SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-h264
          stream-format: avc
              alignment: au
  
  SINK template: 'sink'
    Availability: Always
    Capabilities:
      video/x-raw(memory:DroidVideoMetaData)
                 format: { (string)YV12 }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]
...

[defaultuser@Xperia10III ~]$ /usr/bin/gst-inspect-1.0 droidvdec
...
  SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-raw(memory:DroidMediaQueueBuffer)
                 format: { (string)NV12_64Z32, (string)YV12, (string)NV16, (string)NV12, (string)NV21, (string)YUY2, (string)RGBA, (string)RGBx, (string)RGB, (string)RGB16, (string)BGRA, (string)ENCODED }
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]
      video/x-raw
                 format: I420
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
              framerate: [ 0/1, 2147483647/1 ]
  
  SINK template: 'sink'
    Availability: Always
    Capabilities:
      video/x-h264
          stream-format: avc
              alignment: au
      video/x-vp9
      video/x-h265
...
1 Like

hi ,how to use droidvenc in pipeline?

The pipelines for encoding? They look something like this (records default sinc to ogg/vorbis):

gst-launch-1.0 pulsesrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=blah.ogg

https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html?gi-language=c

I would guess there is no support for x265 because of the license costs, but that’s just a guess. I haven’t used gst-launch for video encoding since I generally just use ffmpeg.
Some useful examples at:

A complicated (and nvidia specific example) - droidvenc would go where ‘! nvv4l2h264enc’ appears

     'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, \
     format=(string)NV12, framerate=(fraction)30/1' ! nvv4l2h264enc \
     maxperf-enable=1 bitrate=8000000 ! h264parse ! qtmux ! filesink \
     location=<filename_h264.mp4> -e
2 Likes