我發現在flv.js拉流的時候,他會去取比較舊的資料
例如我直播推流30秒後才拉流,他會從大概20秒前的影像開始撥放
但是如果我一推流就拉流,延遲大概就只有4、5秒
請問要如何解決這個狀況呢?
另外以直播為目標要怎麼降低延遲呢?
ffmpeg -f dshow -i video="USB2.0 VGA UVC WebCam" -c:v libx264 -preset ultrafast -tune zerolatency -r 12 -an -f flv rtmp://3.3.3.3/live/demo
if(flvjs.isSupported()){
console.log("flv is supported");
var streamid = 'demo';
var mediaDataSource = {
type: 'flv',
url: 'https://3.3.3.3/live?port=1935&app=live&stream='+streamid,
hasAudio: false,
isLive: true
};
var element = document.getElementById('debugtest');
if (typeof player != "undefined") {
if (player != null) {
player.unload();
player.detachMediaElement();
player.destroy();
player = null;
}
}
player = flvjs.createPlayer(mediaDataSource);
player.attachMediaElement(element);
player.load();
}
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
interleave off;
wait_key off;
meta on;
wait_video off;
idle_streams off;
sync 100ms;
gop_cache on;
#session_relay on;
#allow publish 127.0.0.1;
#allow publish 192.168.2.0/24;
allow publish all;
#deny publish all;
allow play all;
}
}
}