burak guder
Member
I using rtmp-re-publish for screen share but i am losing data.
FFMPEG OUT :
flashphoner code :;
FFMPEG OUT :
Bash:
Input #0, flv, from 'rtmp://******.com/live/rtmp_rtmp_333_share':
Duration: N/A, start: 325.942000, bitrate: N/A
Stream #0:0: Data: none
Stream #0:1: Video: h264 (Constrained Baseline), yuv420p(progressive), 1280x692, 1k tbr, 1k tbn
Output #0, flv, to 'rtmp://*******:9099/app/test':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (Constrained Baseline) ([7][0][0][0] / 0x0007), yuv420p(progressive), 1280x692, q=2-31, 1k tbr, 1k tbn, 1k tbc
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Press [q] to stop, [?] for help
av_interleaved_write_frame(): Broken pipeB time=00:00:13.72 bitrate= 185.4kbits/s speed= 1x
[flv @ 0x560c8f3a7d40] Failed to update header with correct duration.
[flv @ 0x560c8f3a7d40] Failed to update header with correct filesize.
Error writing trailer of rtmp://**********:9099/app/test: Broken pipe
frame= 284 fps= 21 q=-1.0 Lsize= 311kB time=00:00:13.74 bitrate= 185.1kbits/s speed= 1x
video:305kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.941246%
Conversion failed!
flashphoner code :;
JavaScript:
/******* scream share ****************/
function onExtensionAvailable() {
localVideoShare = document.getElementById("localVideoShare");
onStoppedShare();
}
function onStartedShare(publishStream) {
console.log("BUTTON : onStartedShare");
$("#screensharebutton").off('click').click(function(){
$(this).prop('disabled', true);
publishStream.stop();
$("#screensharebutton").css("color", "#212121");
}).prop('disabled', false);
//$('#mediaSource').prop('disabled', true);
}
function onStoppedShare() {
console.log("BUTTON : onStoppedShare");
$("#screensharebutton").off('click').click(function(){
if (validateFormShare()) {
//muteInputs();
$(this).prop('disabled', true);
startShare();
$("#screensharebutton").css("color", "#ff2727");
//Share_Session.disconnect();
}
}).prop('disabled', false);
//$('#mediaSource').prop('disabled', false);
//unmuteInputs();
}
function startShare() {
//check if we already have session
//var url = googleWS;
//check if we already have session
console.log("startShare ");
if (Flashphoner.getSessions().length > 0) {
var session = Flashphoner.getSessions()[0];
if (session.getServerUrl() == url) {
startStreamingShare(session);
console.log("startStreamingShare ");
return;
} else {
//remove session DISCONNECTED and FAILED callbacks
session.on(SESSION_STATUS.DISCONNECTED, function(){});
session.on(SESSION_STATUS.FAILED, function(){});
console.log("remove session ");
//session.disconnect();
}
}
//console.log("Create new session with url " + url);
Flashphoner.createSession({urlServer: googleSWS}).on(SESSION_STATUS.ESTABLISHED, function(session){
//session connected, start streaming
startStreamingShare(session);
Share_Session = session;
}).on(SESSION_STATUS.DISCONNECTED, function(){
setStatus2(SESSION_STATUS.DISCONNECTED);
onStoppedSahere();
$("#screensharebutton").css("color", "#212121");
}).on(SESSION_STATUS.FAILED, function(){
setStatus2(SESSION_STATUS.FAILED);
onStoppedSahere();
$("#screensharebutton").css("color", "#212121");
});
}
function startStreamingShare(session) {
//var streamName = field("url").split('/')[3];
console.log("Share stream name : ");
var constraints = {
video: {
width: 1280,
height: 720,
//WCS-2014. fixed window/tab sharing
frameRate: 30
}
};
constraints.video.type = "screen";
if ($("#woChromeExtension").prop('checked')) {
constraints.video.withoutExtension = true;
}
if (Browser.isFirefox()){
constraints.video.mediaSource = $('#mediaSource').val();
}
session.createStream({
name: googleID+"_share",
display: localVideoShare,
constraints: constraints,
rtmpUrl: googleServer
}).on(STREAM_STATUS.PUBLISHING, function(publishStream){
/*
* User can stop sharing screen capture using Chrome "stop" button.
* Catch onended video track event and stop publishing.
*/
document.getElementById(publishStream.id()).srcObject.getVideoTracks()[0].onended = function (e) {
publishStream.stop();
};
document.getElementById(publishStream.id()).addEventListener('resize', function(event){
resizeVideo(event.target);
});
console.log("OnstartedShare button active");
setStatus2(STREAM_STATUS.PUBLISHING);
onStartedShare(publishStream);
}).on(STREAM_STATUS.UNPUBLISHED, function(){
setStatus2(STREAM_STATUS.UNPUBLISHED);
//enable start button
onStoppedShare();
$("#screensharebutton").css("color", "#212121");
}).on(STREAM_STATUS.FAILED, function(stream){
setStatus2(STREAM_STATUS.FAILED, stream);
//enable start button
onStoppedShare();
$("#screensharebutton").css("color", "#212121");
}).publish();
}
//show connection or local stream status
function setStatus2(status, stream) {
var statusField = $("#status2");
var infoField = $("#info");
statusField.text(status).removeClass();
if (status == "PUBLISHING") {
statusField.html('<span class="label label-success">Paylaşıldı</span>');
} else if (status == "DISCONNECTED" || status == "UNPUBLISHED") {
statusField.html('<span class="label label-warning">Durduruldu</span>');
//statusField.attr("class","text-muted");
} else if (status == "FAILED") {
statusField.html('<span class="label label-danger">Paylaşılamıyor</span>');
}
}
//install extension
function installExtension() {
if (Browser.isChrome()) {
window.open("https://chrome.google.com/webstore/detail/flashphoner-screen-sharin/nlbaajplpmleofphigmgaifhoikjmbkg");
} else if (Browser.isFirefox()) {
var params = {
"Flashphoner Screen Sharing": { URL: "../../dependencies/screen-sharing/firefox-extension/flashphoner_screen_sharing-0.0.10-fx.xpi",
IconURL: "../../dependencies/screen-sharing/firefox-extension/icon.png",
Hash: "sha1:96699c6536de455cdc5c7705f5b24fae28931605",
toString: function () { return this.URL; }
}
};
InstallTrigger.install(params);
}
}
function installFromMarket() {
if (Browser.isChrome()) {
var url = "https://chrome.google.com/webstore/detail/flashphoner-screen-sharin/nlbaajplpmleofphigmgaifhoikjmbkg";
window.open(url, '_blank');
}
}
function inIframe () {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}
function muteInputs() {
$(":input").each(function() {
$(this).prop('disabled',true);
});
}
function unmuteInputs() {
$(":input").each(function() {
if($(this).attr('id') == 'woChromeExtension' && extensionNotInstalled) {
return;
}
$(this).prop('disabled',false);
});
}
function validateFormShare() {
var valid = true;
/*
$(':text').each(function(){
if (!$(this).val()) {
highlightInput($(this));
valid = false;
} else {
var numericFields = ['fps', 'width', 'height'];
if (numericFields.indexOf(this.id) != -1 && !(parseInt($(this).val()) > 0)) {
highlightInput($(this));
valid = false;
} else {
removeHighlight($(this));
}
}
});
*/
return valid;
function highlightInput(input) {
input.closest('.form-group').addClass("has-error");
}
function removeHighlight(input) {
input.closest('.form-group').removeClass("has-error");
}
}
/********** END *************\