Add support for H.265 in stream component

Agreed this hopefully will get fixed as cameras are moving toward more compressed stream qualities. I can see my cameras on my cell phones and tablets but not on my PC web browser. very disheartening!!

Yeah chrome(pc) still doesn’t support h265 and I don’t think it will in the near future.

1 Like

Works on Edge now, not tried Chrome recently

Indeed it does work on Edge provided you have HEVC extensions installed, but to get it working properly with stream, we need a new release of PyAV that includes this PR I made back in February:
Expose codec_tag in codec_context by uvjustin · Pull Request #748 · PyAV-Org/PyAV · GitHub
PyAV hasn’t been updated in quite some time, so if you see a new release please let me know and I will bump the version in HA.

1 Like

How did you get it working on Edge? I have HEVC extension installed but still the h265 cams shows up blank.

Configuration.yaml looks like this: -

ffmpeg:
stream:
camera:
   - platform: generic
     name: DoorCamera265
     still_image_url: http://192.168.1.10/webcapture.jpg?command=snap
     stream_source: rtsp://192.168.1.10:554/user=xxxx&password=xxxx&channel=1&stream=0.sdp?

and Picture Entity Card Configuration is simply:-

type: picture-entity
entity: camera.doorcamera265
name: ' '
camera_image: camera.doorcamera265
camera_view: live
show_state: false

You might not want live view

Hope that helps

I created a fork of PyAV so we could access the feature needed to get H.265 working in Edge and other chromium builds with H.265 support.
This is in the beta and will be in the 2021.11 release.

2 Likes

Worth mentioning here that I have a Hikvision DS-2CD2455FWD-IW (where do they get these names?!) connected to a Synology Surveillance Station, streaming in H.265+ and, while it does indeed work in Edge, it’s a solid 25 seconds behind real-time. Not complaining, just feeding back.

A similar sort of delay affects my h.264 cameras via Home Assistant (again, same setup to Synology which presents the cameras to HA through the DSM integration) - for the h.264 cameras though, that’s about 7-10 seconds behind real-time.

I overcome this delay using AlexxIT’s WebRTC (HACS integration) for the h.264 cameras when I want to see as near to real-time as possible in HA, but that doesn’t work for the h.265 cameras. Obviously I can use the Synology native Android app if necessary but having a tablet switch to the lovelace card for the camera when motion is detected (and with minimal latency in stream) is the goal.

Still, nice to see h.265 support arriving! Thanks for your work.

1 Like

Glad the H.265 support works for you.
The latency from H.265+ streams is from the large intervals between i-frames. If you want to reduce latency, use the LL-HLS option that was added in 2021.10 and improved in 2021.11.
Stream - Home Assistant (home-assistant.io)
Using the configuration there should help bring your latency down to about 3 seconds even with H.265+.

1 Like

@uvjustin I have 3 cameras with h265+ streams added with the picture-entity cards. I open the Android HA app. In the view where all 3 are shown below each other, I get bufferIncompatibleCodecsError. But when I click on each of them, the stream loads correctly and an almost live view is shown. Shouldn’t those streams load correctly on the view of 3 cards as well? And not just if I tap on them.

On Android, the frontend setting camera_view: live won’t work. Use camera_view: auto instead.
See this comment: Add support for H.265 in stream component - #16 by uvjustin

1 Like

Just a note as I fumble with getting another Hikvision NVR to play nice with HA…the live streams can be pulled up fine on Android 11 (didn’t at first, had to try opening them several times before it suddenly started working.) But in HA/Opera/Windows 10, I just get a flickering panel which barely reads “Error with media stream contents…” I take it that h.265 isn’t supported in Opera. Checking, it isn’t supported in most browsers, and likely won’t be anytime soon, due to licensing issues.

Is there some way to programmatically tell if the stream is renderable? It would be beneficial if HA stopped playback altogether with an “unsupported encoding” message or similar. Or is this like h.264, where it initially wasn’t supported by browsers, then eventually was?

Streaming from this NVR at rtsp://user:pass@NVRipaddress:554/ISAPI/Streaming/channels/102/ works. I noticed that if I typed NVRipaddress:80/ISAPI/Streaming/channels/102 into Opera, it showed XML which stated the stream was h.265 so maybe the tag is present in the RTSP stream also.

It looks like it won’t be supported in most browsers except Safari and Edge. HEVC has been in use for many years now but Google seems quite intent on discouraging its use. If you’re on Mac/iOS there should be no problem with HEVC. On Windows, use MS Edge and install the HEVC windows add on (there used to be a free one but I think now you have to pay a few bucks). On Linux, you can build your own version of chromium with HEVC support.

As of chromium 104 it appears Chrome will finally support HEVC when the --enable-features=PlatformHEVCDecoderSupport is passed in. I just tried it and it works, but I’m not sure if the Windows HEVC extensions are required or not (they are already installed on my system). Currently the release version of Chrome is chromium 102, beta is 103, and dev is 104, so you’ll have to use dev for now. Here’s the link to dev: Google Chrome Developer Tools - Google Chrome

2 Likes

Will this flow into the android app too? My HEVC camera is in the mail so i’m yet to discover the current limitations

The android app has had limited HEVC support (camera card in auto mode only) for a while now. See Add support for H.265 in stream component - #14 by uvjustin above.
Hopefully the Chromium support will flow through to the Android webview, as this will provide a more consistent experience and require less maintenance, but my guess is that won’t happen for at least half a year.

2 Likes

it did not flow threw.

you can view h265 video threw WebpageCard → h265 video
but if you try to view it threw media browser it wont work…

1 Like

Are there any plans to fully integrate h265 in the Android app?
I am not able to watch clips through the media browser, yet if I download them, I’m able to play them on my phone.
I’m using Frigate to record in h265 and it works flawlessly on iOS and Windows 11 (Chrome), but on my Android phone, I always get an error saying that the format is not supported.

1 Like

I’m getting the same, i’ve spent too long trying to problem solve a frigate error and finally found that it’s the HA app not supporting the format, Another vote to update.

would be nice to get feature parity with the iOS app for sure.