licode
licode copied to clipboard
rtsp stream (Room) message: Error subscribing to stream
Environment
Docker installed Ubuntu20
Problem
when I push the rtsp stream, it show the error
(Room) message: Error subscribing to stream
Code
const serverUrl = '/';
let localStream;
let room;
window.onload = function () {
const config = { audio: true, video: true, data: true, videoSize: [640, 480, 640, 480] };
const config2 = { video: true, audio: false, url: "rtsp://172.28.5.201:8554/live/test" };
const config3 = { video: true, audio: false, url: "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4" };
const config4 = {video: true, audio: false, url: "file:///home/fengmao/output.mkv" };
var localStream = Erizo.Stream(config3);
const createToken = (userName, role, callback) => {
const req = new XMLHttpRequest();
const url = `${serverUrl}createToken/`;
const body = { username: userName, role };
req.onreadystatechange = () => {
if (req.readyState === 4) {
callback(req.responseText);
}
};
req.open('POST', url, true);
req.setRequestHeader('Content-Type', 'application/json');
req.send(JSON.stringify(body));
};
createToken('user', 'presenter', (response) => {
const token = response;
console.log(token);
room = Erizo.Room({ token });
localStream.addEventListener("access-accepted", function () {
var subscribeToStreams = function (streams) {
for (var index in streams) {
var stream = streams[index];
if (localStream.getID() !== stream.getID()) {
room.subscribe(stream);
}
}
};
room.addEventListener("room-connected", function (roomEvent) {
room.publish(localStream);
subscribeToStreams(roomEvent.streams);
});
room.addEventListener("stream-subscribed", function(streamEvent) {
var stream = streamEvent.stream;
var div = document.createElement('div');
div.setAttribute("style", "width: 320px; height: 240px;");
div.setAttribute("id", "test" + stream.getID());
document.body.appendChild(div);
stream.play("test" + stream.getID());
});
room.addEventListener("stream-added", function (streamEvent) {
var streams = [];
streams.push(streamEvent.stream);
subscribeToStreams(streams);
});
room.addEventListener("stream-removed", function (streamEvent) {
// Remove stream from DOM
var stream = streamEvent.stream;
if (stream.elementID !== undefined) {
var element = document.getElementById(stream.elementID);
document.body.removeChild(element);
}
});
room.connect();
localStream.play("myVideo");
});
localStream.init();});
};
Console
Terminal
2022-07-26 10:01:15.062 - WARN: Publisher - message: Adding ExternalInput, id: 323619488767148100_rtsp://172.28.5.201:8554/live/test, url: rtsp://172.28.5.201:8554/live/test
[erizo-516952bb-3344-e678-a6e6-1193416cd74d] [rtsp @ 0x4aad740] UDP timeout, retrying with TCP
[erizo-516952bb-3344-e678-a6e6-1193416cd74d] [rtsp @ 0x4aad740] Could not find codec parameters (Video: h264)
[rtsp @ 0x4aad740] Estimating duration from bitrate, this may be inaccurate
[erizo-516952bb-3344-e678-a6e6-1193416cd74d] [libvpx @ 0x4aed960] v1.8.2
[erizo-516952bb-3344-e678-a6e6-1193416cd74d] [libvpx @ 0x4aed960] Failed to initialize encoder: Invalid parameter
[libvpx @ 0x4aed960] Additional information: g_w out of range [1..16383]
Terminal
it is in another pc but it is in a VMWare environment.
2022-07-26 09:02:18.254 - ERROR: RoomController - message: addSubscriber ErizoJS timeout no retry, clientId: 45db2274-5a28-4d80-83c9-b7cddbc4c5fa, streamId: 708019660498276000, erizoId: ErizoJS_b1f827f4-c14e-b951-427d-c2edf0efba88,
2022-07-26 09:02:18.255 - ERROR: ErizoController - Client - message: addSubscriber timeout when contacting ErizoJS, streamId: 708019660498276000, clientId: 45db2274-5a28-4d80-83c9-b7cddbc4c5fa, _id: 62df90ca1a7da2071eb09852, userName: user 7, room: 62d92685c55f2b02949175c5, role: presenter, service: 62d92677b80d2722f0438c51, creationDate: 2022-07-26T06: 59: 22.566Z, mediaConfiguration: default, secure: true, host: 192.168.204.128: 8080
Looking at the logs it seems like a problem with the codec used but I would need more information about the codec used and the configuration parameters.
I tried playing the public rtsp stream that you have in the config3 variable and its working for me. To play the stream you need to publish it with one client and open another tab to subscribe to it because Licode does not allow a client to subscribe to the stream it has published. There are ways to circumvent this restriction if needed.
I open two brower as two brower client. So I donnot need to open two different clients to debug.
I also can see the congfig3 to start a rtp process, but it lose pack and picture. I think it is because the rtsp stream address is too far from my region. So the terminal in ther vmware test show the timeout.
for the rtsp stream in local area network, I think it is because the tcp probem. I push the rtsp h264 stream to the server in the local are network by the way of tcp. Maybe licode need a udp h264 stream to accept.
ffmpeg -f alsa -i pulse -f x11grab -r 30 -s 800x600 -i :0.0 -acodec aac -ac 1 -ar 44100 -qscale 0.01 -vcodec libx264 -preset ultrafast -crf 0 -f rtsp -rtsp_transport tcp rtsp://172.28.5.201:8554/live/test
I can play all the two rtsp stream in the vlc in my computer which has the licode server.