mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Add RTC stream merging demo by FFmpeg. 4.0.97
This commit is contained in:
parent
aa9c4e8604
commit
9fb2b69212
5 changed files with 65 additions and 3 deletions
|
@ -176,6 +176,7 @@ The ports used by SRS:
|
||||||
|
|
||||||
## V4 changes
|
## V4 changes
|
||||||
|
|
||||||
|
* v4.0, 2021-05-03, Add RTC stream merging demo by FFmpeg. 4.0.97
|
||||||
* v4.0, 2021-05-02, Add one to one demo. 4.0.96
|
* v4.0, 2021-05-02, Add one to one demo. 4.0.96
|
||||||
* v4.0, 2021-04-20, Support RTC2RTMP bridger and shared FastTimer. 4.0.95
|
* v4.0, 2021-04-20, Support RTC2RTMP bridger and shared FastTimer. 4.0.95
|
||||||
* v4.0, 2021-04-20, Refine transcoder to support aac2opus and opus2aac. 4.0.94
|
* v4.0, 2021-04-20, Refine transcoder to support aac2opus and opus2aac. 4.0.94
|
||||||
|
|
24
trunk/3rdparty/signaling/www/demos/js/srs.sig.js
vendored
24
trunk/3rdparty/signaling/www/demos/js/srs.sig.js
vendored
|
@ -100,7 +100,6 @@ function SrsRtcSignalingParse(location) {
|
||||||
|
|
||||||
let wsPort = location.href.split('wsp=')[1];
|
let wsPort = location.href.split('wsp=')[1];
|
||||||
wsPort = wsPort? wsPort.split('&')[0] : location.host.split(':')[1];
|
wsPort = wsPort? wsPort.split('&')[0] : location.host.split(':')[1];
|
||||||
wsHost = wsPort? wsHost.split(':')[0] + ':' + wsPort : wsHost;
|
|
||||||
|
|
||||||
let host = location.href.split('host=')[1];
|
let host = location.href.split('host=')[1];
|
||||||
host = host? host.split('&')[0] : location.hostname;
|
host = host? host.split('&')[0] : location.hostname;
|
||||||
|
@ -114,6 +113,29 @@ function SrsRtcSignalingParse(location) {
|
||||||
let autostart = location.href.split('autostart=')[1];
|
let autostart = location.href.split('autostart=')[1];
|
||||||
autostart = autostart && autostart.split('&')[0] === 'true';
|
autostart = autostart && autostart.split('&')[0] === 'true';
|
||||||
|
|
||||||
|
// Remove data in query.
|
||||||
|
if (query) {
|
||||||
|
query = query.replace('wss=' + wsSchema, '');
|
||||||
|
query = query.replace('wsh=' + wsHost, '');
|
||||||
|
query = query.replace('wsp=' + wsPort, '');
|
||||||
|
if (room) {
|
||||||
|
query = query.replace('room=' + room, '');
|
||||||
|
}
|
||||||
|
query = query.replace('display=' + display, '');
|
||||||
|
query = query.replace('autostart=' + autostart, '');
|
||||||
|
|
||||||
|
while (query.indexOf('&&') >= 0) {
|
||||||
|
query = query.replace('&&', '&');
|
||||||
|
}
|
||||||
|
query = query.replace('?&', '?');
|
||||||
|
if (query.lastIndexOf('?') == query.length - 1) {
|
||||||
|
query = query.substr(0, query.length - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regenerate the host of websocket.
|
||||||
|
wsHost = wsPort? wsHost.split(':')[0] + ':' + wsPort : wsHost;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
query: query, wsSchema: wsSchema, wsHost: wsHost, host: host,
|
query: query, wsSchema: wsSchema, wsHost: wsHost, host: host,
|
||||||
room: room, display: display, autostart: autostart,
|
room: room, display: display, autostart: autostart,
|
||||||
|
|
37
trunk/3rdparty/signaling/www/demos/one2one.html
vendored
37
trunk/3rdparty/signaling/www/demos/one2one.html
vendored
|
@ -63,6 +63,25 @@
|
||||||
<a href="javascript:control_alert_peer()">Alert</a>
|
<a href="javascript:control_alert_peer()">Alert</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="accordion">
|
||||||
|
<div class="accordion-group">
|
||||||
|
<div class="accordion-heading">
|
||||||
|
<a href="#" id="ff_preview" target="_blank" class="accordion-toggle">
|
||||||
|
FFmpeg合流转直播预览:rtmp://<span class="ff_host"></span>/<span class="ff_app"></span>/merge
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="accordion-body collapse in">
|
||||||
|
<div class="accordion-inner">
|
||||||
|
ffmpeg -f flv -i rtmp://<span class="ff_host"></span>/<span class="ff_app"></span>/<span class="ff_first"></span> -f flv -i rtmp://<span class="ff_host"></span>/<span class="ff_app"></span>/<span class="ff_second"></span> \ <br/>
|
||||||
|
-filter_complex "[1:v]scale=w=96:h=72[ckout];[0:v][ckout]overlay=x=W-w-10:y=H-h-10[out]" -map "[out]" \ <br/>
|
||||||
|
-c:v libx264 -profile:v high -preset medium \ <br/>
|
||||||
|
-filter_complex amix -c:a aac \ <br/>
|
||||||
|
-f flv -y rtmp://<span class="ff_host"></span>/<span class="ff_app"></span>/merge
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var sig = null;
|
var sig = null;
|
||||||
|
@ -139,6 +158,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var startPublish = function (host, room, display) {
|
var startPublish = function (host, room, display) {
|
||||||
|
$(".ff_first").each(function(i,e) {
|
||||||
|
$(e).text(display);
|
||||||
|
});
|
||||||
|
|
||||||
var url = 'webrtc://' + host + '/' + room + '/' + display + conf.query;
|
var url = 'webrtc://' + host + '/' + room + '/' + display + conf.query;
|
||||||
$('#rtc_media_publisher').show();
|
$('#rtc_media_publisher').show();
|
||||||
$('#publisher').show();
|
$('#publisher').show();
|
||||||
|
@ -153,7 +176,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
return publisher.publish(url).then(function(session){
|
return publisher.publish(url).then(function(session){
|
||||||
$('#self').text('Self: ' + display);
|
$('#self').text('Self: ' + url);
|
||||||
}).catch(function (reason) {
|
}).catch(function (reason) {
|
||||||
publisher.close();
|
publisher.close();
|
||||||
$('#rtc_media_publisher').hide();
|
$('#rtc_media_publisher').hide();
|
||||||
|
@ -162,6 +185,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
var startPlay = function (host, room, display) {
|
var startPlay = function (host, room, display) {
|
||||||
|
$(".ff_second").each(function(i,e) {
|
||||||
|
$(e).text(display);
|
||||||
|
});
|
||||||
|
|
||||||
var url = 'webrtc://' + host + '/' + room + '/' + display + conf.query;
|
var url = 'webrtc://' + host + '/' + room + '/' + display + conf.query;
|
||||||
$('#rtc_media_player').show();
|
$('#rtc_media_player').show();
|
||||||
$('#player').show();
|
$('#player').show();
|
||||||
|
@ -192,6 +219,14 @@
|
||||||
conf.room && $('#txt_room').val(conf.room);
|
conf.room && $('#txt_room').val(conf.room);
|
||||||
$('#txt_display').val(conf.display);
|
$('#txt_display').val(conf.display);
|
||||||
|
|
||||||
|
$(".ff_host").each(function(i,e) {
|
||||||
|
$(e).text(conf.host);
|
||||||
|
});
|
||||||
|
$(".ff_app").each(function(i,e) {
|
||||||
|
$(e).text($('#txt_room').val());
|
||||||
|
});
|
||||||
|
$('#ff_preview').attr('href', 'http://ossrs.net/players/srs_player.html?app=' + $('#txt_room').val() + '&stream=merge.flv&server=' + conf.host + '&vhost=' + conf.host + '&autostart=true');
|
||||||
|
|
||||||
$("#btn_start").click(startDemo);
|
$("#btn_start").click(startDemo);
|
||||||
if (conf.autostart) {
|
if (conf.autostart) {
|
||||||
startDemo();
|
startDemo();
|
||||||
|
|
|
@ -1012,6 +1012,10 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcStreamDescripti
|
||||||
return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "rtmp stream %s busy", r->get_stream_url().c_str());
|
return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "rtmp stream %s busy", r->get_stream_url().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable GOP cache for RTC2RTMP bridger, to keep the streams in sync,
|
||||||
|
// especially for stream merging.
|
||||||
|
rtmp->set_cache(false);
|
||||||
|
|
||||||
SrsRtmpFromRtcBridger *bridger = new SrsRtmpFromRtcBridger(rtmp);
|
SrsRtmpFromRtcBridger *bridger = new SrsRtmpFromRtcBridger(rtmp);
|
||||||
if ((err = bridger->initialize(r)) != srs_success) {
|
if ((err = bridger->initialize(r)) != srs_success) {
|
||||||
srs_freep(bridger);
|
srs_freep(bridger);
|
||||||
|
|
|
@ -26,6 +26,6 @@
|
||||||
|
|
||||||
#define VERSION_MAJOR 4
|
#define VERSION_MAJOR 4
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 96
|
#define VERSION_REVISION 97
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue