Al
Al
SMSoftware Mansion
Created by Al on 2/19/2024 in #membrane-help
WebRTC stream not working
I've hit an issue trying to get an MPEGTS stream displaying in the browser via WebRTC. All seems to work, I can add the WebRTC endpoint for the stream, to the RTC Engine, the web client successfully connects, negotiates tracks, handles the offer and sdpanswer etc and I can add the transceiver for the stream to the RTCPeerConnection and get the MediaStream. When I add the MediaStream to the video element srcObject I get a blank screen with a spinner and see a continuous stream of Didn't receive keyframe for variant: messages on the server side:
[debug] Responding to STUN request [UDP, session q02, anonymous, client 100.120.41.48:50473]
[debug] No callback function specified for 'stun_query' hook [UDP, session q02, anonymous, client 100.120.41.48:50473]
[debug] <0.2875.0>/{:endpoint, "6adebe85-148e-4fc7-b06d-3246d0b345bd"}/:endpoint_bin/:ice Sending Binding Indication with params: [magic: 554869826, transaction_id: 27660277917344572907996316102]
[debug] <0.2875.0>/{:endpoint, "6adebe85-148e-4fc7-b06d-3246d0b345bd"}/:endpoint_bin/:ice Received Binding Request with params: [priority: 1853825279, magic: 554869826, trid: 27653466564182733022482168431, username: "JBcs:+aQz", use_candidate: true, ice_controlled: false, ice_controlling: true]
[debug] <0.2875.0>/{:endpoint, "6adebe85-148e-4fc7-b06d-3246d0b345bd"}/:endpoint_bin/:ice Sending Binding Success with params: [magic: 554869826, transaction_id: 27653466564182733022482168431, username: "JBcs:+aQz"]
[debug] <0.2875.0>/{:endpoint, "ed395134-d9c5-4f8e-b4a5-5274c0319487"}/{:track_sender, "07DB486FABD21734"} Didn't receive keyframe for variant: high in 500. Retrying.
...
[debug] Responding to STUN request [UDP, session q02, anonymous, client 100.120.41.48:50473]
[debug] No callback function specified for 'stun_query' hook [UDP, session q02, anonymous, client 100.120.41.48:50473]
[debug] <0.2875.0>/{:endpoint, "6adebe85-148e-4fc7-b06d-3246d0b345bd"}/:endpoint_bin/:ice Sending Binding Indication with params: [magic: 554869826, transaction_id: 27660277917344572907996316102]
[debug] <0.2875.0>/{:endpoint, "6adebe85-148e-4fc7-b06d-3246d0b345bd"}/:endpoint_bin/:ice Received Binding Request with params: [priority: 1853825279, magic: 554869826, trid: 27653466564182733022482168431, username: "JBcs:+aQz", use_candidate: true, ice_controlled: false, ice_controlling: true]
[debug] <0.2875.0>/{:endpoint, "6adebe85-148e-4fc7-b06d-3246d0b345bd"}/:endpoint_bin/:ice Sending Binding Success with params: [magic: 554869826, transaction_id: 27653466564182733022482168431, username: "JBcs:+aQz"]
[debug] <0.2875.0>/{:endpoint, "ed395134-d9c5-4f8e-b4a5-5274c0319487"}/{:track_sender, "07DB486FABD21734"} Didn't receive keyframe for variant: high in 500. Retrying.
...
Any clues as to what I'm missing would be greatly received. For context, I followed the RTC Engine file example and have a main pipeline taking the video output from the MPEGTS demuxer and delivering it to a WebRTC endpoint bin.
23 replies
SMSoftware Mansion
Created by Al on 1/4/2024 in #membrane-help
Custom RTC Endpoint
Sorry, more random questions! What's the best place to start when trying to get a custom endpoint to stream mpegts video in real-time to the browser? I have a working pipeline for mpegts in a UDP stream rendering in the browser via HLS - basically UDP -> MpegTS -> Demuxer -> H264 Parser -> HttpAdaptiveStream. My application is real-time so the HLS lag is too much so WebRTC seems like the way to go. I've had a look at the RTSP Endpoint and am trying to create an equivalent for MpegTS received via UDP but have hit the limit of my understanding. I add my endpoint to the RTC Engine and it initialises, connects to the UDP stream, gets the MpegTS PMT and I can happily demux and parse the H264 video and wrap it up with RTP. I'm guessing that I need to wait for handle_pad_added before finalising the pipeline to feed that out via a TrackSender. My question is does that handle_pad_added callback only get called if I connect the browser to the associated peer?
4 replies
SMSoftware Mansion
Created by Al on 12/28/2023 in #membrane-help
HTTPAdaptiveStream issue with hls.js
I was wondering if anyone else has experieneced this issues with HLS? I have a working pipeline generating HLS output which plays fine with Safari and it's native support for HLS. However, when trying to get playback working in Chrome using hls.js it seems to stick at the buffering stage. It downloads the index.m3u8 file which looks like this:
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-STREAM-INF:BANDWIDTH=22658039,AVERAGE-BANDWIDTH=20974091,RESOLUTION=1920x1080,CODECS="avc1.4d0028"
g3cFdmlkZW8.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-STREAM-INF:BANDWIDTH=22658039,AVERAGE-BANDWIDTH=20974091,RESOLUTION=1920x1080,CODECS="avc1.4d0028"
g3cFdmlkZW8.m3u8
but doesn't then download the reference g3cFdmlkZW8.m3u8 file. This is all using Core v 1.0.0. The HTTPAdaptiveStream Bin setup is:
child(:video_out,
%Membrane.HTTPAdaptiveStream.SinkBin{
manifest_module: Membrane.HTTPAdaptiveStream.HLS,
mode: :live,
target_window_duration: :infinity,
persist?: true,
storage: %Membrane.HTTPAdaptiveStream.Storages.FileStorage{directory: hls_path}
},
get_if_exists: true)
child(:video_out,
%Membrane.HTTPAdaptiveStream.SinkBin{
manifest_module: Membrane.HTTPAdaptiveStream.HLS,
mode: :live,
target_window_duration: :infinity,
persist?: true,
storage: %Membrane.HTTPAdaptiveStream.Storages.FileStorage{directory: hls_path}
},
get_if_exists: true)
4 replies
SMSoftware Mansion
Created by Al on 12/5/2023 in #membrane-help
RTP stream
I'm trying to get a simple RTP stream pipeline working but hit the following error:
16:22:57.782 [error] GenServer #PID<0.308.0> terminating
** (KeyError) key #Reference<0.1227858978.1981546498.158967> not found in: %{}
:erlang.map_get(#Reference<0.1227858978.1981546498.158967>, %{})
(membrane_rtp_plugin 0.24.1) lib/membrane/rtp/session_bin.ex:430: Membrane.RTP.SessionBin.handle_pad_added/3
16:22:57.782 [error] GenServer #PID<0.308.0> terminating
** (KeyError) key #Reference<0.1227858978.1981546498.158967> not found in: %{}
:erlang.map_get(#Reference<0.1227858978.1981546498.158967>, %{})
(membrane_rtp_plugin 0.24.1) lib/membrane/rtp/session_bin.ex:430: Membrane.RTP.SessionBin.handle_pad_added/3
This appears to be due to the ssrc_pt_mapping being empty - how does this get populated? This is my initial pipeline:
child(:video_src,
%Membrane.UDP.Source{
local_address: {127, 0, 0, 1},
local_port_no: 1234
})
|> via_in(:rtp_input)
|> child(:rtp, Membrane.RTP.SessionBin)
|> child(:out, %Membrane.File.Sink{location: "tmp.ts"})
child(:video_src,
%Membrane.UDP.Source{
local_address: {127, 0, 0, 1},
local_port_no: 1234
})
|> via_in(:rtp_input)
|> child(:rtp, Membrane.RTP.SessionBin)
|> child(:out, %Membrane.File.Sink{location: "tmp.ts"})
The one key difference from the demo is I'm streaming an mpeg ts payload so payload type is 33. All works fine with ffplay so I guess I'm missing something in the Membrane setup.
12 replies