Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebRTC stream will not open after its closed #1560

Open
franconoronha opened this issue Jan 20, 2025 · 2 comments
Open

WebRTC stream will not open after its closed #1560

franconoronha opened this issue Jan 20, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@franconoronha
Copy link

franconoronha commented Jan 20, 2025

My WebRTC streams are working fine the first time they're open. But won't start again on after producer is stopped. This is on version 1.9.8, but I have tried on 1.9.5 and had the same results.

Logs:

18:35:53.441 DBG [webrtc] new consumer src=T01_r
18:35:53.534 DBG [ffmpeg] bin libavformat="61.  7.100" version=7.1-full_build-www.gyan.dev
18:35:53.535 DBG [exec] run rtsp args=["C:\\ProgramData\\chocolatey\\bin\\ffmpeg","-hide_banner","-v","error","-allowed_media_types","video","-r","30","-fflags","nobuffer","-timeout","5000000","-user_agent","go2rtc/ffmpeg","-rtsp_flags","prefer_tcp","-i","rtsp://*****:*******@********:554/Interface/Cameras/Media?Camera=T01&Profile=Recording","-codec:v","libx264","-g:v","30","-bf:v","0","-preset:v","veryfast","-tune:v","zerolatency","-profile:v","main","-level:v","4.1","-an","-user_agent","ffmpeg/go2rtc","-rtsp_transport","tcp","-f","rtsp","rtsp://127.0.0.1:8554/692c610a510caf1e519f7b6edc355c20"]
18:35:58.442 DBG [exec] run rtsp launch=4.9064558s
18:35:58.443 DBG [streams] start producer url=ffmpeg:rtsp://****:******@******:554/Interface/Cameras/Media?Camera=T01&Profile=Recording#media=video#video=h264
18:36:08.511 DBG [streams] stop producer url=ffmpeg:rtsp://****:******@******:554/Interface/Cameras/Media?Camera=T01&Profile=Recording#media=video#video=h264
18:36:18.509 DBG [webrtc] new consumer src=T01_r

Nothing happens after that.

Configs:

api:
  origin: '*'
log:
  level: debug
  format: text
ffmpeg:
  bin: C:\ProgramData\chocolatey\bin\ffmpeg
  rtsp: "-r 30 -fflags nobuffer -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i {input}"
  h264: "-codec:v libx264 -g:v 30 -bf:v 0 -preset:v veryfast -tune:v zerolatency -profile:v main -level:v 4.1"
webrtc:
  listen: ":8555"
  candidates:
    - ********:8555
streams:
        T01_v:
          - ffmpeg:rtsp://****:*****@********:554/Interface/Cameras/Media?Camera=T01&Profile=Visualization#media=video#video=h264

Have tried some possibly unrelated things like changing candidates to stun:8555 and changing to tcp or udp, no result.

@AlexxIT AlexxIT added the question Further information is requested label Jan 21, 2025
@AlexxIT
Copy link
Owner

AlexxIT commented Jan 21, 2025

Check stream info after stream closed. You can also check http://ip:1984/api/stacks url.

@franconoronha
Copy link
Author

franconoronha commented Jan 21, 2025

I'm going to post them here, since I don't really know what to do with this information.
Info after trying to re-open stream (I changed ffmpeg bin so I wouldn't need chocolatey):

{
  "producers": [
    {
      "id": 2,
      "format_name": "rtsp",
      "protocol": "rtsp+tcp",
      "remote_addr": "127.0.0.1:61808 forwarded ip:554",
      "source": "exec:ffmpeg -hide_banner -v error -allowed_media_types video -r 30 -fflags nobuffer -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i rtsp://***:*****@ip:554/Interface/Cameras/Media?Camera=T01\u0026Profile=Visualization -codec:v libx264 -g:v 30 -bf:v 0 -preset:v veryfast -tune:v zerolatency -profile:v main -level:v 4.1 -an -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp rtsp://127.0.0.1:8554/6d9d23bf1759c8bf6abfbdf9f6d95fd1",
      "url": "rtsp://***:*****@ip:554/Interface/Cameras/Media?Camera=T01\u0026Profile=Visualization",
      "sdp": "v=0\r\no=- 0 0 IN IP4 127.0.0.1\r\ns=_\r\nc=IN IP4 127.0.0.1\r\nt=0 0\r\na=tool:libavformat 61.7.100\r\nm=video 0 RTP/AVP 96\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z01AKdoCwPaEAAADAAQAAAMA8jxgyoA=,aO8PyA==; profile-level-id=4D4029\r\na=control:streamid=0\r\n",
      "user_agent": "ffmpeg/go2rtc",
      "medias": [
        "video, recvonly, H264"
      ],
      "receivers": [
        {
          "id": 3,
          "codec": {
            "codec_name": "h264",
            "codec_type": "video",
            "level": 41,
            "profile": "Main"
          },
          "bytes": 2046895,
          "packets": 1742
        }
      ],
      "bytes_recv": 2067883
    }
  ],
  "consumers": []
}

http://ip:1984/api/stack after trying to re-open stream.

goroutine 60 [syscall, 6 minutes]:
syscall.Syscall6(0x1f4?, 0xc000047c20?, 0x867c7c?, 0xd49674?, 0xd42160?, 0xc0000f4000?, 0x1f4?, 0x22ce9a0a748?)
	runtime/syscall_windows.go:463 +0x38
syscall.readFile(0x304, {0xc00000e000?, 0x8000, 0x137e220?}, 0xc00002e420?, 0x800000?)
	syscall/zsyscall_windows.go:1019 +0x8b
syscall.ReadFile(...)
	syscall/syscall_windows.go:443
syscall.Read(0xc000370488?, {0xc00000e000?, 0x0?, 0xc0000439a0?})
	syscall/syscall_windows.go:422 +0x2d
internal/poll.(*FD).Read(0xc000370488, {0xc00000e000, 0x8000, 0x8000})
	internal/poll/fd_windows.go:424 +0x1b9
os.(*File).read(...)
	os/file_posix.go:29
os.(*File).Read(0xc000076798, {0xc00000e000?, 0xc180e0?, 0xc000008360?})
	os/file.go:124 +0x52
io.copyBuffer({0xe7c3a0, 0xc00011dce0}, {0xe7d280, 0xc000130008}, {0x0, 0x0, 0x0})
	io/io.go:429 +0x191
io.Copy(...)
	io/io.go:388
os.genericWriteTo(0x0?, {0xe7c3a0, 0xc00011dce0})
	os/file.go:275 +0x4f
os.(*File).WriteTo(0x137a400?, {0xe7c3a0?, 0xc00011dce0?})
	os/file.go:253 +0x49
io.copyBuffer({0xe7c3a0, 0xc00011dce0}, {0xe7c7c0, 0xc000076798}, {0x0, 0x0, 0x0})
	io/io.go:411 +0x9d
io.Copy(...)
	io/io.go:388
os/exec.(*Cmd).writerDescriptor.func1()
	os/exec/exec.go:580 +0x34
os/exec.(*Cmd).Start.func2(0x0?)
	os/exec/exec.go:733 +0x2c
created by os/exec.(*Cmd).Start in goroutine 26
	os/exec/exec.go:732 +0xa25

goroutine 61 [chan receive, 6 minutes]:
os/exec.(*Cmd).awaitGoroutines(0xc000002000, 0x0)
	os/exec/exec.go:957 +0x1f1
os/exec.(*Cmd).Wait(0xc000002000)
	os/exec/exec.go:924 +0x156
github.com/AlexxIT/go2rtc/internal/exec.handleRTSP.func2()
	github.com/AlexxIT/go2rtc/internal/exec/exec.go:157 +0x25
created by github.com/AlexxIT/go2rtc/internal/exec.handleRTSP in goroutine 26
	github.com/AlexxIT/go2rtc/internal/exec/exec.go:156 +0x369

goroutine 67 [sync.Mutex.Lock, 6 minutes]:
sync.runtime_SemacquireMutex(0xc000347ec8?, 0x3a?, 0x0?)
	runtime/sema.go:95 +0x25
sync.(*Mutex).lockSlow(0xc000228dec)
	sync/mutex.go:173 +0x15d
sync.(*Mutex).Lock(...)
	sync/mutex.go:92
github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Start(0xc000228c40)
	github.com/AlexxIT/go2rtc/pkg/rtsp/producer.go:48 +0x8f
github.com/AlexxIT/go2rtc/internal/streams.(*Producer).worker(0xc0001261b0, {0xe82940?, 0xc000228c40?}, 0x1)
	github.com/AlexxIT/go2rtc/internal/streams/producer.go:161 +0x2f
created by github.com/AlexxIT/go2rtc/internal/streams.(*Producer).start in goroutine 26
	github.com/AlexxIT/go2rtc/internal/streams/producer.go:157 +0x198

goroutine 124 [chan receive, 6 minutes]:
os/exec.(*Cmd).awaitGoroutines(0xc000002000, 0x0)
	os/exec/exec.go:957 +0x1f1
os/exec.(*Cmd).Wait(0xc000002000)
	os/exec/exec.go:924 +0x156
github.com/AlexxIT/go2rtc/internal/exec.(*closer).Close(0xc0002961f0)
	github.com/AlexxIT/go2rtc/internal/exec/closer.go:38 +0x285
github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Close(0xc000228c40)
	github.com/AlexxIT/go2rtc/pkg/rtsp/client.go:330 +0x83
github.com/AlexxIT/go2rtc/pkg/rtsp.(*Conn).Stop(0xc000228c40)
	github.com/AlexxIT/go2rtc/pkg/rtsp/producer.go:94 +0x105
github.com/AlexxIT/go2rtc/internal/streams.(*Producer).stop(0xc0001261b0)
	github.com/AlexxIT/go2rtc/internal/streams/producer.go:263 +0x12f
github.com/AlexxIT/go2rtc/internal/streams.(*Stream).stopProducers(0xc000134380)
	github.com/AlexxIT/go2rtc/internal/streams/stream.go:115 +0xe5
github.com/AlexxIT/go2rtc/internal/streams.(*Stream).RemoveConsumer(0xc000134380, {0xe81670, 0xc0001f4580})
	github.com/AlexxIT/go2rtc/internal/streams/stream.go:75 +0x21f
github.com/AlexxIT/go2rtc/internal/webrtc.asyncHandler.func1({0xc48400?, 0x134f230?})
	github.com/AlexxIT/go2rtc/internal/webrtc/webrtc.go:157 +0x9b
github.com/AlexxIT/go2rtc/pkg/core.(*Listener).Fire(...)
	github.com/AlexxIT/go2rtc/pkg/core/listener.go:16
github.com/AlexxIT/go2rtc/pkg/webrtc.NewConn.func5(0x6)
	github.com/AlexxIT/go2rtc/pkg/webrtc/conn.go:129 +0x68
created by github.com/pion/webrtc/v3.(*PeerConnection).onConnectionStateChange in goroutine 167
	github.com/pion/webrtc/[email protected]/peerconnection.go:496 +0x16f

goroutine 197 [select]:
github.com/pion/interceptor/pkg/report.(*SenderInterceptor).loop(0xc00013a080, {0xe7dae0, 0xc000597eb0})
	github.com/pion/[email protected]/pkg/report/sender_interceptor.go:116 +0x1bc
created by github.com/pion/interceptor/pkg/report.(*SenderInterceptor).BindRTCPWriter in goroutine 194
	github.com/pion/[email protected]/pkg/report/sender_interceptor.go:100 +0x10c

goroutine 194 [sync.Mutex.Lock, 6 minutes]:
sync.runtime_SemacquireMutex(0xc00055dbd8?, 0x16?, 0x22ceecf3988?)
	runtime/sema.go:95 +0x25
sync.(*Mutex).lockSlow(0xc00012622c)
	sync/mutex.go:173 +0x15d
sync.(*Mutex).Lock(...)
	sync/mutex.go:92
github.com/AlexxIT/go2rtc/internal/streams.(*Producer).Dial(0xc0001261b0)
	github.com/AlexxIT/go2rtc/internal/streams/producer.go:58 +0x52
github.com/AlexxIT/go2rtc/internal/streams.(*Stream).AddConsumer(0xc000134380, {0xe81670, 0xc000356dc0})
	github.com/AlexxIT/go2rtc/internal/streams/add_consumer.go:36 +0x68d
github.com/AlexxIT/go2rtc/internal/webrtc.asyncHandler(0xc0000d6af0, 0xc000602080)
	github.com/AlexxIT/go2rtc/internal/webrtc/webrtc.go:185 +0x6d7
github.com/AlexxIT/go2rtc/internal/api/ws.apiWS.func2()
	github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:134 +0x39
created by github.com/AlexxIT/go2rtc/internal/api/ws.apiWS in goroutine 128
	github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:133 +0x366

goroutine 198 [select, 6 minutes]:
github.com/pion/interceptor/pkg/twcc.(*SenderInterceptor).loop(0xc000016420, {0xe7dae0, 0xc000597eb0})
	github.com/pion/[email protected]/pkg/twcc/sender_interceptor.go:180 +0xfb
created by github.com/pion/interceptor/pkg/twcc.(*SenderInterceptor).BindRTCPWriter in goroutine 194
	github.com/pion/[email protected]/pkg/twcc/sender_interceptor.go:93 +0x14c

goroutine 196 [select]:
github.com/pion/interceptor/pkg/report.(*ReceiverInterceptor).loop(0xc0000163c0, {0xe7dae0, 0xc000597eb0})
	github.com/pion/[email protected]/pkg/report/receiver_interceptor.go:100 +0x16c
created by github.com/pion/interceptor/pkg/report.(*ReceiverInterceptor).BindRTCPWriter in goroutine 194
	github.com/pion/[email protected]/pkg/report/receiver_interceptor.go:89 +0x10c

goroutine 195 [select]:
github.com/pion/interceptor/pkg/nack.(*GeneratorInterceptor).loop(0xc000016360, {0xe7dae0, 0xc000597eb0})
	github.com/pion/[email protected]/pkg/nack/generator_interceptor.go:149 +0x11c
created by github.com/pion/interceptor/pkg/nack.(*GeneratorInterceptor).BindRTCPWriter in goroutine 194
	github.com/pion/[email protected]/pkg/nack/generator_interceptor.go:83 +0x10c

Total: 19, Skipped: 10

@AlexxIT AlexxIT self-assigned this Jan 21, 2025
@AlexxIT AlexxIT added bug Something isn't working and removed question Further information is requested labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants