Skip to content

Video decoding & encoding

KonstaT edited this page Apr 2, 2025 · 9 revisions

How to enable H.264 hardware video decoding & encoding and H.265 hardware video decoding

It is possible to use Android software audio/video decoders & encoders, FFmpeg software audio/video decoders, FFmpeg H.264/H.265 hardware video decoders, or v4l2_codec2 H.264 hardware video decoder & encoder. Codec ranks are use to determine which decoder/encoder is used. Default rank for Android software video decoders & encoders is 512 and software audio decoders & encoders is 8. Use a higher rank (smaller value) to prefer some other decoder & encoder.

With the following default settings Android software audio decoders & encoders are preferred over FFmpeg software audio decoders, FFmpeg software video decoders are preferred over Android software video decoders, FFmpeg H.265 hardware decoder is used, and v4l2_codec2 H.264 hardware video decoder & encoder is preferred over others.

rpi4 has H.264 hardware video decoder & encoder and H.265 hardware video decoder. rpi5 has H.265 hardware video decoder.

Edit device/brcm/rpi5/vendor.prop and adjust values of following properties.

# FFmpeg
persist.vendor.ffmpeg_codec2.rank.audio=16
persist.vendor.ffmpeg_codec2.rank.video=256
persist.vendor.ffmpeg_codec2.v4l2.h264=false
persist.vendor.ffmpeg_codec2.v4l2.h265=true
# V4L2
persist.vendor.v4l2_codec2.rank.decoder=128
persist.vendor.v4l2_codec2.rank.encoder=128
Clone this wiki locally