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
4.25k stars 346 forks source link

Q: Proper config for HDHomeRun device endpoint (MPEG-TS format)? #726

Closed patdemko closed 10 months ago

patdemko commented 10 months ago

I've been struggling with how to get video streams from my HDHomeRun devices into go2rtc. I'm guessing it's either not supported or I'm doing the configuration wrong.

From the development guide an http request will start a MPEG-TS stream so I tried using the below config, but it's not working.

streams: channel2: http://10.X.X.X:5004/auto/v2.1

Looking at a pcap between the elements when I try to view the stream in go2rtc, I see the http request out from go2rtc and then some data transfer happens, but eventually it gets reset by go2rtc. It tries it again, the same thing happens and it stops.

image

Does anyone know if this is a configuration issue on my part or if it's not supported? I can provide good pcaps of data actually being sent if needed.

AlexxIT commented 10 months ago

You can send me a dump in PM or post it here. Also you can try to use ffmpeg source.

patdemko commented 10 months ago

You can send me a dump in PM or post it here. Also you can try to use ffmpeg source.

Here you go. I'll also give the ffmpeg source a try when I can. Thanks! HDHomeRun_capture.zip

patdemko commented 10 months ago

I did try using the ffmpeg source for this with limited success (video is very choppy & audio was good), but it's probably because I didn't have the parameters set properly to change the bitrate and couldn't figure it out. I also wasn't able to get #video=h264/vaapi or #video=h264#hardware to work. I am using the go2rtc that comes bundled with the frigate docker if it matters. Here's the config that was able to give me the choppy video and good audio.

test: ffmpeg:http://10.13.1.101:5004/auto/v2.1#video=h264#audio=aac/16000

Also the current way I'm getting getting this feed to a WebRTC one for viewing on a tablet without go2rtc is to run a ffmpeg command that I found online and modified into a script (below). It starts up a linuxserver.io ffmpeg container that outputs files that are then shared with an nginx container.

#!/bin/bash
# variables - ffmpeg_container_name file_path input_stream width height m3u8_filename webserver_port
docker run --rm -it -d \
  --name $1 \
  --device=/dev/dri:/dev/dri \
  -v $2':/config' \
  linuxserver/ffmpeg \
  -vaapi_device /dev/dri/renderD128 \
  -i $3 \
  -c:v h264_vaapi \
  -b:v 2000000 \
  -vf 'format=nv12|vaapi,hwupload,scale_vaapi=w='$4':h='$5 \
  -c:a aac -b:a 160000 -ac 2 \
  -hls_time 10 -hls_list_size 10 -start_number 1 -hls_flags delete_segments \
  /config/$6.m3u8
docker run -it --rm -d -p $7:80 --name $1'_web' -v $2':/usr/share/nginx/html' nginx

Any help with accomplishing something similar with go2rtc with the ffmpeg source would be appreciated.

Thanks!

AlexxIT commented 10 months ago

Well. It's some awful non standard mpegts without any video description. I don't think go2rtc or ffmpeg can handle it.

patdemko commented 10 months ago

Well. It's some awful non standard mpegts without any video description. I don't think go2rtc or ffmpeg can handle it.

Well thanks for looking! I get lost quick when looking at how various equipment handles these streams and what's standard or not. Like I said I do have it working directly with ffmpeg using that above referenced command so I can just keep using that method for getting TV channels to a browser on my tablets. I was only trying to simplify that process by using go2rtc.