mirror of
https://github.com/v0l/zap-stream-core.git
synced 2025-06-21 06:00:45 +00:00
fix: hls output fix
This commit is contained in:
@ -56,7 +56,7 @@ impl HlsEgress {
|
||||
let mut opts = HashMap::new();
|
||||
opts.insert(
|
||||
"hls_segment_filename".to_string(),
|
||||
base.join("%v/live.m3u8").to_string_lossy().to_string(),
|
||||
format!("{}/%v/%05d.ts", base.display()),
|
||||
);
|
||||
opts.insert("master_pl_name".to_string(), "live.m3u8".to_string());
|
||||
opts.insert("master_pl_publish_rate".to_string(), "10".to_string());
|
||||
@ -65,7 +65,11 @@ impl HlsEgress {
|
||||
|
||||
let muxer = unsafe {
|
||||
let mut m = Muxer::builder()
|
||||
.with_output_path(base.to_str().unwrap(), Some("hls"), Some(opts))?
|
||||
.with_output_path(
|
||||
base.join("%v/live.m3u8").to_str().unwrap(),
|
||||
Some("hls"),
|
||||
Some(opts),
|
||||
)?
|
||||
.build()?;
|
||||
for e in encoded {
|
||||
m.add_stream_encoder(e)?;
|
||||
|
@ -109,6 +109,13 @@ impl PipelineRunner {
|
||||
.iter()
|
||||
.filter(|v| v.src_index() == src_index as usize);
|
||||
for var in pkt_vars {
|
||||
let enc = if let Some(enc) = self.encoders.get_mut(&var.id()) {
|
||||
enc
|
||||
} else {
|
||||
//warn!("Frame had nowhere to go in {} :/", var.id());
|
||||
continue;
|
||||
};
|
||||
|
||||
let frame = match var {
|
||||
VariantStream::Video(v) => {
|
||||
if let Some(s) = self.scalers.get_mut(&v.id()) {
|
||||
@ -119,7 +126,9 @@ impl PipelineRunner {
|
||||
}
|
||||
VariantStream::Audio(a) => {
|
||||
if let Some(r) = self.resampler.get_mut(&a.id()) {
|
||||
r.process_frame(frame)?
|
||||
let frame_size = (*enc.codec_context()).frame_size;
|
||||
// TODO: resample audio fifo
|
||||
r.process_frame(frame, frame_size)?
|
||||
} else {
|
||||
frame
|
||||
}
|
||||
@ -127,18 +136,13 @@ impl PipelineRunner {
|
||||
_ => frame,
|
||||
};
|
||||
|
||||
let packets = if let Some(enc) = self.encoders.get_mut(&var.id()) {
|
||||
enc.encode_frame(frame)?
|
||||
} else {
|
||||
//warn!("Frame had nowhere to go in {} :/", var.id());
|
||||
continue;
|
||||
};
|
||||
|
||||
let packets = enc.encode_frame(frame)?;
|
||||
// pass new packets to egress
|
||||
for eg in self.egress.iter_mut() {
|
||||
for pkt in packets.iter() {
|
||||
eg.process_pkt(*pkt, &var.id())?;
|
||||
for mut pkt in packets {
|
||||
for eg in self.egress.iter_mut() {
|
||||
eg.process_pkt(pkt, &var.id())?;
|
||||
}
|
||||
av_packet_free(&mut pkt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ impl Webhook {
|
||||
codec: 86018,
|
||||
channels: 2,
|
||||
sample_rate: 48_000,
|
||||
sample_fmt: "flt".to_owned(),
|
||||
sample_fmt: "fltp".to_owned(),
|
||||
}));
|
||||
}
|
||||
|
||||
@ -83,16 +83,16 @@ impl Webhook {
|
||||
id: Uuid::new_v4(),
|
||||
variants: vars,
|
||||
egress: vec![
|
||||
EgressType::Recorder(EgressConfig {
|
||||
/*EgressType::Recorder(EgressConfig {
|
||||
name: "REC".to_owned(),
|
||||
out_dir: self.config.output_dir.clone(),
|
||||
variants: var_ids,
|
||||
}),
|
||||
/*EgressType::HLS(EgressConfig {
|
||||
}),*/
|
||||
EgressType::HLS(EgressConfig {
|
||||
name: "HLS".to_owned(),
|
||||
out_dir: self.config.output_dir.clone(),
|
||||
variants: var_ids,
|
||||
}),*/
|
||||
}),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user