mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-22 11:30:59 +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-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-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"] }
|
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"
|
chrono = "0.4"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
|
@ -16,7 +16,7 @@ use std::path::{Path, PathBuf};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use anyhow::{anyhow, Error};
|
use anyhow::{anyhow, Error};
|
||||||
use chrono::{DateTime, Duration, SecondsFormat, Utc};
|
use chrono::{DateTime, Duration, Utc};
|
||||||
use m3u8_rs::{
|
use m3u8_rs::{
|
||||||
AlternativeMedia, AlternativeMediaType, MasterPlaylist, MediaPlaylist, MediaSegment,
|
AlternativeMedia, AlternativeMediaType, MasterPlaylist, MediaPlaylist, MediaSegment,
|
||||||
VariantStream,
|
VariantStream,
|
||||||
|
@ -45,7 +45,7 @@ impl State {
|
||||||
all_mimes.dedup();
|
all_mimes.dedup();
|
||||||
|
|
||||||
let playlist = MasterPlaylist {
|
let playlist = MasterPlaylist {
|
||||||
version: 7,
|
version: Some(7),
|
||||||
variants: self
|
variants: self
|
||||||
.video_streams
|
.video_streams
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -57,9 +57,12 @@ impl State {
|
||||||
|
|
||||||
VariantStream {
|
VariantStream {
|
||||||
uri: path.as_path().display().to_string(),
|
uri: path.as_path().display().to_string(),
|
||||||
bandwidth: stream.bitrate.to_string(),
|
bandwidth: stream.bitrate,
|
||||||
codecs: Some(all_mimes.join(",")),
|
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()),
|
audio: Some("audio".to_string()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
@ -124,9 +127,9 @@ struct StreamState {
|
||||||
|
|
||||||
struct VideoStream {
|
struct VideoStream {
|
||||||
name: String,
|
name: String,
|
||||||
bitrate: u32,
|
bitrate: u64,
|
||||||
width: i32,
|
width: u64,
|
||||||
height: i32,
|
height: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AudioStream {
|
struct AudioStream {
|
||||||
|
@ -185,7 +188,7 @@ fn update_manifest(state: &mut StreamState) {
|
||||||
trim_segments(state);
|
trim_segments(state);
|
||||||
|
|
||||||
let playlist = MediaPlaylist {
|
let playlist = MediaPlaylist {
|
||||||
version: 7,
|
version: Some(7),
|
||||||
target_duration: 2.5,
|
target_duration: 2.5,
|
||||||
media_sequence: state.media_sequence,
|
media_sequence: state.media_sequence,
|
||||||
segments: state
|
segments: state
|
||||||
|
@ -201,11 +204,7 @@ fn update_manifest(state: &mut StreamState) {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
program_date_time: if idx == 0 {
|
program_date_time: if idx == 0 {
|
||||||
Some(
|
Some(segment.date_time.into())
|
||||||
segment
|
|
||||||
.date_time
|
|
||||||
.to_rfc3339_opts(SecondsFormat::Millis, false),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
|
@ -444,7 +443,7 @@ impl VideoStream {
|
||||||
|
|
||||||
src.set_property("is-live", true);
|
src.set_property("is-live", true);
|
||||||
enc.set_property("bframes", 0u32);
|
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");
|
enc.set_property_from_str("tune", "zerolatency");
|
||||||
mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500));
|
mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500));
|
||||||
mux.set_property_from_str("header-update-mode", "update");
|
mux.set_property_from_str("header-update-mode", "update");
|
||||||
|
|
|
@ -33,9 +33,9 @@ struct StreamState {
|
||||||
|
|
||||||
struct VideoStream {
|
struct VideoStream {
|
||||||
name: String,
|
name: String,
|
||||||
bitrate: u32,
|
bitrate: u64,
|
||||||
width: i32,
|
width: u64,
|
||||||
height: i32,
|
height: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AudioStream {
|
struct AudioStream {
|
||||||
|
@ -68,7 +68,7 @@ impl State {
|
||||||
all_mimes.dedup();
|
all_mimes.dedup();
|
||||||
|
|
||||||
let playlist = MasterPlaylist {
|
let playlist = MasterPlaylist {
|
||||||
version: 7,
|
version: Some(7),
|
||||||
variants: self
|
variants: self
|
||||||
.video_streams
|
.video_streams
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -80,9 +80,12 @@ impl State {
|
||||||
|
|
||||||
VariantStream {
|
VariantStream {
|
||||||
uri: path.as_path().display().to_string(),
|
uri: path.as_path().display().to_string(),
|
||||||
bandwidth: stream.bitrate.to_string(),
|
bandwidth: stream.bitrate,
|
||||||
codecs: Some(all_mimes.join(",")),
|
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()),
|
audio: Some("audio".to_string()),
|
||||||
..Default::default()
|
..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());
|
println!("writing manifest to {}", path.display());
|
||||||
|
|
||||||
let playlist = MediaPlaylist {
|
let playlist = MediaPlaylist {
|
||||||
version: 7,
|
version: Some(7),
|
||||||
target_duration: 2.5,
|
target_duration: 2.5,
|
||||||
media_sequence: 0,
|
media_sequence: 0,
|
||||||
segments: state
|
segments: state
|
||||||
|
@ -335,7 +338,7 @@ impl VideoStream {
|
||||||
|
|
||||||
src.set_property("num-buffers", 300);
|
src.set_property("num-buffers", 300);
|
||||||
enc.set_property("bframes", 0u32);
|
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("fragment-duration", gst::ClockTime::from_mseconds(2500));
|
||||||
mux.set_property_from_str("header-update-mode", "update");
|
mux.set_property_from_str("header-update-mode", "update");
|
||||||
mux.set_property("write-mehd", true);
|
mux.set_property("write-mehd", true);
|
||||||
|
|
Loading…
Reference in a new issue