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
5.07k stars 405 forks source link

ADTS to magic producer not working properly #832

Closed bropat closed 5 months ago

bropat commented 10 months ago

Hi @AlexxIT,

I have tested the implementation #745 with the Bitstream ADTS audio support and unfortunately 0 audio data packets arrive at the consumer and therefore no audio is played back. I also carried out the test you mentioned here without success. I connected VLC via rtsp and tested it as a consumer without success.

Tested with following config:

{
   "api":{
      "listen":":1984"
   },
   "rtsp":{
      "listen":":8554"
   },
   "srtp":{
      "listen":":8443"
   },
   "webrtc":{
      "listen":":8555"
   },
   "streams":{
      "camera1":null,
   },
   "log":{
      "level":"debug",
      "api":"debug",
      "exec":"debug",
      "ngrok":"debug",
      "rtsp":"debug",
      "streams":"debug",
      "webrtc":"debug"
   }
}

Audio sended with:

ffmpeg -re -i audio-stream.dump.txt -c copy -f adts http://localhost:1984/api/stream?dst=camera1

Tested audio file:

audio-stream.dump.txt

Connected with VLC to:

rtsp://localhost:8554/camera1

image

image

image

go2rtc log output:

11:45:50.113 INF go2rtc version 1.8.4 linux/amd64
11:45:50.113 INF [api] listen addr=:1984
11:45:50.114 INF [rtsp] listen addr=:8554
11:45:50.114 INF [webrtc] listen addr=:8555
11:45:50.114 DBG [hass] can't import config: open .storage/core.config_entries: no such file or directory
11:45:55.934 DBG [rtsp] new consumer stream=camera1
11:45:55.934 WRN [rtsp] error="streams: unknown error" stream=camera1
11:45:56.268 DBG [rtsp] new consumer stream=camera1
11:45:56.268 WRN [rtsp] error="streams: unknown error" stream=camera1
11:46:00.804 DBG [rtsp] new consumer stream=camera1
11:46:11.321 DBG [rtsp] handle=EOF
11:46:11.321 DBG [rtsp] disconnect stream=camera1

If you need anything more, please let me know.

bropat commented 10 months ago

go2rtc log output level trace:

12:01:40.210 INF go2rtc version 1.8.4 linux/amd64
12:01:40.211 TRC [api] register path path=/
12:01:40.211 TRC [api] register path path=/api
12:01:40.211 TRC [api] register path path=/api/config
12:01:40.211 TRC [api] register path path=/api/exit
12:01:40.211 TRC [api] register path path=/api/restart
12:01:40.211 INF [api] listen addr=:1984
12:01:40.211 TRC [api] register path path=/api/ws
12:01:40.211 TRC [api] register path path=/api/streams
12:01:40.212 INF [rtsp] listen addr=:8554
12:01:40.212 INF [webrtc] listen addr=:8555
12:01:40.212 TRC [api] register path path=/api/webrtc
12:01:40.212 TRC [api] register path path=/api/frame.mp4
12:01:40.212 TRC [api] register path path=/api/stream.mp4
12:01:40.212 TRC [api] register path path=/api/stream.m3u8
12:01:40.212 TRC [api] register path path=/api/hls/playlist.m3u8
12:01:40.212 TRC [api] register path path=/api/hls/segment.ts
12:01:40.212 TRC [api] register path path=/api/hls/init.mp4
12:01:40.212 TRC [api] register path path=/api/hls/segment.m4s
12:01:40.212 TRC [api] register path path=/api/frame.jpeg
12:01:40.212 TRC [api] register path path=/api/stream.mjpeg
12:01:40.212 TRC [api] register path path=/static
12:01:40.212 TRC [api] register path path=/streams
12:01:40.212 TRC [api] register path path=/stream/
12:01:40.212 DBG [hass] can't import config: open .storage/core.config_entries: no such file or directory
12:01:40.213 TRC [api] register path path=/api/hass
12:01:40.213 TRC [api] register path path=/onvif/
12:01:40.213 TRC [api] register path path=/api/onvif
12:01:40.213 TRC [api] register path path=/api/webtorrent
12:01:40.213 TRC [api] register path path=/api/stream.flv
12:01:40.213 TRC [api] register path path=/api/ffmpeg/devices
12:01:40.213 TRC [api] register path path=/api/ffmpeg/hardware
12:01:40.213 TRC [api] register path path=/api/stream
12:01:40.213 TRC [api] register path path=/api/dvrip
12:01:40.213 TRC [api] register path path=/api/stream.ts
12:01:40.213 TRC [api] register path path=/api/stream.aac
12:01:40.213 TRC [api] register path path=/api/roborock
12:01:40.213 TRC [api] register path path=/api/homekit
12:01:40.213 TRC [api] register path path=/api/nest
12:01:40.213 TRC [api] register path path=/api/gopro
12:01:40.213 TRC [api] register path path=/api/stack
12:01:51.383 TRC [api] POST /api/stream?dst=camera1 127.0.0.1:46186
12:01:52.608 TRC [rtsp] server request:
OPTIONS rtsp://localhost:8554/camera1 RTSP/1.0
Cseq: 2
User-Agent: LibVLC/3.0.20 (LIVE555 Streaming Media v2016.11.28)

12:01:52.608 TRC [rtsp] server response:
RTSP/1.0 200 OK
Cseq: 2
Public: OPTIONS, SETUP, TEARDOWN, DESCRIBE, PLAY, PAUSE, ANNOUNCE, RECORD

12:01:52.609 TRC [rtsp] server request:
DESCRIBE rtsp://localhost:8554/camera1 RTSP/1.0
Cseq: 3
User-Agent: LibVLC/3.0.20 (LIVE555 Streaming Media v2016.11.28)
Accept: application/sdp

12:01:52.609 DBG [rtsp] new consumer stream=camera1
12:01:52.609 TRC [streams] check cons=0 media=audio, sendonly, ANY
12:01:52.609 TRC [streams] skip prod= error="streams: unsupported scheme: "
12:01:52.609 TRC [streams] check prod=1 media=audio, recvonly, MPEG4-GENERIC/16000/1
12:01:52.609 TRC [streams] match prod=1 => cons=0
12:01:52.609 TRC [streams] check cons=0 media=video, sendonly, ANY
12:01:52.609 TRC [streams] skip prod= error="streams: unsupported scheme: "
12:01:52.609 TRC [streams] check prod=1 media=audio, recvonly, MPEG4-GENERIC/16000/1
12:01:52.609 DBG [streams] can't stop none producer
12:01:52.609 TRC [rtsp] server response:
RTSP/1.0 200 OK
Content-Type: application/sdp
Cseq: 3
Content-Length: 263

v=0
o=- 1 1 IN IP4 0.0.0.0
s=go2rtc/1.8.4
c=IN IP4 0.0.0.0
t=0 0
m=audio 0 RTP/AVP 96
a=rtpmap:96 MPEG4-GENERIC/16000/1
a=fmtp:96 streamtype=5;profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1408
a=control:trackID=0

12:01:52.610 TRC [rtsp] server request:
SETUP rtsp://localhost:8554/camera1/trackID=0 RTSP/1.0
Cseq: 4
User-Agent: LibVLC/3.0.20 (LIVE555 Streaming Media v2016.11.28)
Transport: RTP/AVP;unicast;client_port=58202-58203

12:01:52.610 TRC [rtsp] server response:
RTSP/1.0 461 Unsupported transport
Cseq: 4

12:01:52.611 TRC [rtsp] server request:
SETUP rtsp://localhost:8554/camera1/trackID=0 RTSP/1.0
Cseq: 5
User-Agent: LibVLC/3.0.20 (LIVE555 Streaming Media v2016.11.28)
Transport: RTP/AVP/TCP;unicast;interleaved=0-1

12:01:52.611 TRC [rtsp] server response:
RTSP/1.0 200 OK
Transport: RTP/AVP/TCP;unicast;interleaved=0-1
Cseq: 5
Session: 87834244;timeout=60

12:01:52.612 TRC [rtsp] server request:
PLAY rtsp://localhost:8554/camera1 RTSP/1.0
Cseq: 6
User-Agent: LibVLC/3.0.20 (LIVE555 Streaming Media v2016.11.28)
Session: 87834244
Range: npt=0.000-

12:01:52.612 TRC [rtsp] server response:
RTSP/1.0 200 OK
Cseq: 6
Session: 87834244

12:02:03.128 TRC [rtsp] server request:
TEARDOWN rtsp://localhost:8554/camera1 RTSP/1.0
Cseq: 7
User-Agent: LibVLC/3.0.20 (LIVE555 Streaming Media v2016.11.28)
Session: 87834244

12:02:03.128 DBG [rtsp] handle=EOF
12:02:03.128 DBG [streams] can't stop none producer
12:02:03.128 DBG [streams] can't stop external producer
12:02:03.128 DBG [rtsp] disconnect stream=camera1
AlexxIT commented 10 months ago

All works fine with your file. Try to add -stream_loop -1. Maybe your file run out at the moment you open VLC

fuatakgun commented 9 months ago

btw, I was able to make this work inside home assistant but trying to keep up with both audio and video data at the same time was not scalable inside home assistant, so skipped it

fuatakgun commented 9 months ago

create a separate thread to publish audio data into go2rtc: https://github.com/fuatakgun/eufy_security/blob/master/custom_components/eufy_security/eufy_security_api/p2p_streamer.py#L93

bropat commented 9 months ago

@AlexxIT I have also tried the Big Buck Bunny video, but I have the same result, only with video and no audio packets arrive at the other end. I have also tried sending just the audio stream with the same result. Apart from the trace log above, is there any way I can get more debugging information from go2rtc?

@fuatakgun Thanks for the feedback!

AlexxIT commented 5 months ago

Please let me know if the problem is relevant

bropat commented 2 months ago

I tested version 1.9.4 and everything works perfectly now.