AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
6.63k stars 478 forks source link

Support HLS streaming #53

Closed wvdeadhead closed 1 year ago

wvdeadhead commented 2 years ago

Please consider adding the capability of an HLS output for direct streaming to Google Nest Hub/Google Chromecast devices.

calisro commented 2 years ago

But webrtc doesn't support HLS. But I stream just fine to my Nest hub and other devices using this with ffmpeg to handle any codec corrections.

wvdeadhead commented 2 years ago

Would you mind sharing your config? I want to stream directly from go2rtc to a Nest Hub via a script. Currently, with either Dahua or Unifi cameras, there is significant video delay and no audio, although both types of cameras have supported AAC audio enabled.

My thought regarding HLS, it could be another transcoding flag and would allow for better compatibility with Chromecast devices of multiple generations.

calisro commented 2 years ago

It depends on what codecs the camera has. If when streaming to the nest hub for example if there's no audio, then just concentrate on that part:

  kitchen_main:
    - rtsp://xxxxxx@10.100.1.133/h264Preview_01_main
    - ffmpeg:rtsp://xxxxx@10.100.1.133/h264Preview_01_main#audio=opus

That just adds the opus codec to the set of available codecs. Opus should be usable on the nest hub.

Once you have that, you can send this to your nest hub:

http://ha.local:1984/webrtc.html?src=kitchen_main

My thought regarding HLS, it could be another transcoding flag and would allow for better compatibility with Chromecast devices of multiple generations.

But HLS is already in Home Assistant as teh default. You don't need this to use HLS.

AlexxIT commented 2 years ago

I don't like this format. Not suitable for real-time streaming. Maybe someday, but not in priority.

luzik commented 2 years ago

I believe that HLS is used as live attachments to IOS notification. With HA HLS, it take few seconds to load the stream, so we believe that go2rtc could improve HA in that field :)

AlexxIT commented 2 years ago

This is not HA or go2rtc problem. HLS format was build for streaming. Not for real-time streaming. LL-HLS has some improvement with delay. But it is very complicated and not so good as WebRTC at anyway.

wvdeadhead commented 2 years ago

Thanks for all the comments. I was hoping to use go2rtc as a "universal" conversion that interfaces with everything... like the image on the main page. No worries if HLS isn't an option, was just wishful thinking.

@calisro, I've tried configs identical to yours, with and without Opus, but no audio will play regardless. Opus doesn't seem to be a valid MP4 or HLS audio container.

As much as I love Home Assistant, it's implementation of HLS (or streaming in general) isn't the greatest. I have buffering issues and delay, unlike what I've experienced with either this or the previous project.

AlexxIT commented 2 years ago

The image on the home page shows HLS as the source. There is no lie there :)

AlexxIT commented 1 year ago

Supported in v1.1.0

lindsaymarkward commented 1 year ago

Hi. This issue is the closest I can find to my current problem. I am using a Home Assistant (HA) rich iphone message notification with a camera. It works for my other cameras not using go2rtc (Reolink and a generic IP camera with RTSP). When I send one of my go2rtc web cameras (USB web cams on a Raspberry Pi using RTSP), I get the following error instead of the camera image:

HLS stream unavailable Got non-200 status code (502)

go2rtc version: 1.6.2 Config looks like:

streams:
  lounge: ffmpeg:device?video=0&resolution=1280x720#video=h264

I see above that this should be supported. I would appreciate any help on this matter, thank you!

AlexxIT commented 1 year ago

I don't understand where you get this error

lindsaymarkward commented 1 year ago

Thanks for the reply and thanks in advance for helping :) I see it instead on my iPhone or Apple Watch instead of the stream. With my other cameras, I see the message text and an image from the camera. I can click on (long-press) the notification to see a live camera stream. With my two go2rtc cameras, I get an image with this error text in red. I've attached screenshots from my phone.

IMG_2884

IMG_2885

AlexxIT commented 1 year ago

I think this message related to Hass and not related to go2rtc. This HLS not from go2rtc