mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-25 21:11:00 +00:00
fmp4: Update to m3u8-rs 5
This commit is contained in:
parent
8b11aee04d
commit
d058c96596
3 changed files with 25 additions and 23 deletions
|
@ -25,7 +25,7 @@ path = "src/lib.rs"
|
|||
gst-app = { package = "gstreamer-app", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_18"] }
|
||||
gst-check = { package = "gstreamer-check", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_18"] }
|
||||
gst-pbutils = { package = "gstreamer-pbutils", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_20"] }
|
||||
m3u8-rs = "4.0"
|
||||
m3u8-rs = "5.0"
|
||||
chrono = "0.4"
|
||||
|
||||
[build-dependencies]
|
||||
|
|
|
@ -16,7 +16,7 @@ use std::path::{Path, PathBuf};
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use anyhow::{anyhow, Error};
|
||||
use chrono::{DateTime, Duration, SecondsFormat, Utc};
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use m3u8_rs::{
|
||||
AlternativeMedia, AlternativeMediaType, MasterPlaylist, MediaPlaylist, MediaSegment,
|
||||
VariantStream,
|
||||
|
@ -45,7 +45,7 @@ impl State {
|
|||
all_mimes.dedup();
|
||||
|
||||
let playlist = MasterPlaylist {
|
||||
version: 7,
|
||||
version: Some(7),
|
||||
variants: self
|
||||
.video_streams
|
||||
.iter()
|
||||
|
@ -57,9 +57,12 @@ impl State {
|
|||
|
||||
VariantStream {
|
||||
uri: path.as_path().display().to_string(),
|
||||
bandwidth: stream.bitrate.to_string(),
|
||||
bandwidth: stream.bitrate,
|
||||
codecs: Some(all_mimes.join(",")),
|
||||
resolution: Some(format!("{}x{}", stream.width, stream.height)),
|
||||
resolution: Some(m3u8_rs::Resolution {
|
||||
width: stream.width,
|
||||
height: stream.height,
|
||||
}),
|
||||
audio: Some("audio".to_string()),
|
||||
..Default::default()
|
||||
}
|
||||
|
@ -124,9 +127,9 @@ struct StreamState {
|
|||
|
||||
struct VideoStream {
|
||||
name: String,
|
||||
bitrate: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
bitrate: u64,
|
||||
width: u64,
|
||||
height: u64,
|
||||
}
|
||||
|
||||
struct AudioStream {
|
||||
|
@ -185,7 +188,7 @@ fn update_manifest(state: &mut StreamState) {
|
|||
trim_segments(state);
|
||||
|
||||
let playlist = MediaPlaylist {
|
||||
version: 7,
|
||||
version: Some(7),
|
||||
target_duration: 2.5,
|
||||
media_sequence: state.media_sequence,
|
||||
segments: state
|
||||
|
@ -201,11 +204,7 @@ fn update_manifest(state: &mut StreamState) {
|
|||
..Default::default()
|
||||
}),
|
||||
program_date_time: if idx == 0 {
|
||||
Some(
|
||||
segment
|
||||
.date_time
|
||||
.to_rfc3339_opts(SecondsFormat::Millis, false),
|
||||
)
|
||||
Some(segment.date_time.into())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
|
@ -444,7 +443,7 @@ impl VideoStream {
|
|||
|
||||
src.set_property("is-live", true);
|
||||
enc.set_property("bframes", 0u32);
|
||||
enc.set_property("bitrate", self.bitrate / 1000u32);
|
||||
enc.set_property("bitrate", self.bitrate as u32 / 1000u32);
|
||||
enc.set_property_from_str("tune", "zerolatency");
|
||||
mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500));
|
||||
mux.set_property_from_str("header-update-mode", "update");
|
||||
|
|
|
@ -33,9 +33,9 @@ struct StreamState {
|
|||
|
||||
struct VideoStream {
|
||||
name: String,
|
||||
bitrate: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
bitrate: u64,
|
||||
width: u64,
|
||||
height: u64,
|
||||
}
|
||||
|
||||
struct AudioStream {
|
||||
|
@ -68,7 +68,7 @@ impl State {
|
|||
all_mimes.dedup();
|
||||
|
||||
let playlist = MasterPlaylist {
|
||||
version: 7,
|
||||
version: Some(7),
|
||||
variants: self
|
||||
.video_streams
|
||||
.iter()
|
||||
|
@ -80,9 +80,12 @@ impl State {
|
|||
|
||||
VariantStream {
|
||||
uri: path.as_path().display().to_string(),
|
||||
bandwidth: stream.bitrate.to_string(),
|
||||
bandwidth: stream.bitrate,
|
||||
codecs: Some(all_mimes.join(",")),
|
||||
resolution: Some(format!("{}x{}", stream.width, stream.height)),
|
||||
resolution: Some(m3u8_rs::Resolution {
|
||||
width: stream.width,
|
||||
height: stream.height,
|
||||
}),
|
||||
audio: Some("audio".to_string()),
|
||||
..Default::default()
|
||||
}
|
||||
|
@ -226,7 +229,7 @@ fn setup_appsink(appsink: &gst_app::AppSink, name: &str, path: &Path, is_video:
|
|||
println!("writing manifest to {}", path.display());
|
||||
|
||||
let playlist = MediaPlaylist {
|
||||
version: 7,
|
||||
version: Some(7),
|
||||
target_duration: 2.5,
|
||||
media_sequence: 0,
|
||||
segments: state
|
||||
|
@ -335,7 +338,7 @@ impl VideoStream {
|
|||
|
||||
src.set_property("num-buffers", 300);
|
||||
enc.set_property("bframes", 0u32);
|
||||
enc.set_property("bitrate", self.bitrate / 1000u32);
|
||||
enc.set_property("bitrate", self.bitrate as u32 / 1000u32);
|
||||
mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500));
|
||||
mux.set_property_from_str("header-update-mode", "update");
|
||||
mux.set_property("write-mehd", true);
|
||||
|
|
Loading…
Reference in a new issue