Skip to content

Commit 56a6331

Browse files
committed
feat: ws_h264, 消息堆积时,仅丢弃非关键视频帧
1 parent 3acbedc commit 56a6331

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use river::util::spawn_and_log_error;
88
#[derive(Clap, Debug)]
99
#[clap(version = crate_version ! (), author = "Ninthakeey <ninthakeey@hotmail.com>")]
1010
struct Opts {
11-
#[clap(long, default_value = "0", about = "disabled if port is 0")]
12-
http_player_port: u16,
1311
#[clap(long, default_value = "0", about = "disabled if port is 0")]
1412
http_flv_port: u16,
15-
#[clap(long, default_value = "0", about = "disabled if port is 0")]
13+
#[clap(long, default_value = "18000", about = "disabled if port is 0")]
14+
http_player_port: u16,
15+
#[clap(long, default_value = "18001", about = "disabled if port is 0")]
1616
ws_h264_port: u16,
1717
#[clap(long, default_value = "0", about = "disabled if port is 0")]
1818
ws_fmp4_port: u16,

src/ws_h264.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ fn rtmp_rx_into_mix_rx(rx: Receiver<RtmpMessage>, stream_name: String) -> impl S
8383

8484
let mut mixes = mixes.into_iter().skip_while(|mix| !mix.is_key_frame()).collect::<Vec<Mix>>();
8585

86-
// 消息堆积,丢弃非关键帧
87-
if rx.len() > 3 {
88-
mixes.retain(|x| x.is_key_frame());
86+
// 消息堆积,丢弃视频非关键帧
87+
if rx.len() > 30 {
88+
mixes.retain(|x| x.is_audio() || x.is_key_frame());
8989
}
9090

9191
if mixes.is_empty() {

static/player.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
$(function main() {
4747
jmuxer = new JMuxer({
48-
flushingTime: 100,
48+
flushingTime: 50,
4949
fps: 30,
5050
node: 'player',
5151
mode: 'both', /* available values are: both, audio and video */
@@ -103,9 +103,9 @@
103103
function forward_latest_frame(video) {
104104
if (video && video.buffered && video.buffered.end(0)) {
105105
let latest = video.buffered.end(0);
106-
if (latest - video.currentTime > 0.3) {
106+
console.log(`[forward_latest_frame] latest=${latest}, video.buffered.length=${video.buffered.length}`);
107+
if (latest - video.currentTime > 0.2) {
107108
video.currentTime = latest;
108-
console.log(`[forward_latest_frame] latest=${latest}`);
109109
}
110110
}
111111
}

0 commit comments

Comments
 (0)