fix(iced-video): Fix the very high ram usage
feat(playback): add GstPlayFlags for playbin and playbin3
This commit is contained in:
@@ -9,7 +9,7 @@ gst.workspace = true
|
||||
iced_core = "0.14.0"
|
||||
iced_futures = "0.14.0"
|
||||
iced_renderer = { version = "0.14.0", features = ["iced_wgpu"] }
|
||||
iced_wgpu = "0.14.0"
|
||||
iced_wgpu = { version = "0.14.0" }
|
||||
thiserror = "2.0.17"
|
||||
tracing = "0.1.43"
|
||||
|
||||
@@ -21,3 +21,6 @@ tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
|
||||
debug = true
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
||||
# [patch.crates-io]
|
||||
# iced_wgpu = { git = "https://github.com/uttarayan21/iced", branch = "0.14" }
|
||||
|
||||
@@ -52,8 +52,6 @@ impl State {
|
||||
pub fn new() -> Self {
|
||||
let video = VideoHandle::new("https://jellyfin.tsuba.darksailor.dev/Items/6010382cf25273e624d305907010d773/Download?api_key=036c140222464878862231ef66a2bc9c")
|
||||
.expect("Failed to create video handle");
|
||||
// let video = VideoHandle::new("file:///run/user/1000/gvfs/smb-share:server=tsuba.darksailor.dev,share=nas/Movies/Spider-Man - No Way Home (2021)/Spider-Man.No.Way.Home.2021.UHD.BluRay.2160p.TrueHD.Atmos.7.1.DV.HEVC.REMUX-FraMeSToR.mkv")
|
||||
// .expect("Failed to create video handle");
|
||||
Self { video }
|
||||
}
|
||||
}
|
||||
@@ -71,8 +69,6 @@ pub fn update(state: &mut State, message: Message) -> iced::Task<Message> {
|
||||
match message {
|
||||
Message::Load => {
|
||||
// does stuff
|
||||
// let src = state.video.source().clone();
|
||||
// iced::Task::perform(src.wait(), |_| Message::Loaded)
|
||||
iced::Task::none()
|
||||
}
|
||||
Message::Play => {
|
||||
|
||||
@@ -106,6 +106,7 @@ impl iced_wgpu::Primitive for VideoFrame {
|
||||
.map_readable()
|
||||
.expect("BUG: Failed to map gst::Buffer readable");
|
||||
queue.write_buffer(&video.buffer, 0, &data);
|
||||
drop(data);
|
||||
video
|
||||
.ready
|
||||
.store(false, std::sync::atomic::Ordering::SeqCst);
|
||||
|
||||
@@ -5,7 +5,7 @@ use gst::{
|
||||
caps::{Caps, CapsType},
|
||||
element::ElementExt,
|
||||
pipeline::PipelineExt,
|
||||
playback::Playbin3,
|
||||
playback::{PlayFlags, Playbin, Playbin3},
|
||||
videoconvertscale::VideoConvert,
|
||||
};
|
||||
use std::sync::{Arc, Mutex, atomic::AtomicBool};
|
||||
@@ -34,20 +34,21 @@ impl VideoSource {
|
||||
appsink
|
||||
.drop(true)
|
||||
.sync(true)
|
||||
.async_(true)
|
||||
// .async_(true)
|
||||
.emit_signals(true)
|
||||
.caps(
|
||||
Caps::builder(CapsType::Video)
|
||||
.field("format", "RGBA")
|
||||
.field("format", "RGB10A2_LE") // Forced for now
|
||||
.build(),
|
||||
);
|
||||
let video_sink = videoconvert.link(&appsink).change_context(Error)?;
|
||||
let playbin = gst::plugins::playback::Playbin3::new("iced-video")
|
||||
let playbin = Playbin3::new("iced-video")
|
||||
.change_context(Error)?
|
||||
.with_uri(url.as_ref())
|
||||
.with_buffer_duration(core::time::Duration::from_secs(2))
|
||||
.with_buffer_size(4096 * 4096 * 4 * 3)
|
||||
.with_ring_buffer_max_size(4096 * 4096 * 4 * 3)
|
||||
.with_flags(PlayFlags::default() | PlayFlags::DOWNLOAD)
|
||||
.with_video_sink(&video_sink);
|
||||
let bus = playbin.bus().change_context(Error)?;
|
||||
playbin.pause().change_context(Error)?;
|
||||
@@ -90,10 +91,7 @@ impl VideoSource {
|
||||
}
|
||||
|
||||
pub fn is_playing(&self) -> Result<bool> {
|
||||
let state = self
|
||||
.playbin
|
||||
.state(core::time::Duration::from_millis(0))
|
||||
.change_context(Error)?;
|
||||
let state = self.playbin.state(None).change_context(Error)?;
|
||||
Ok(state == gst::State::Playing)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user