[fix]: preview videos not showing up
This commit is contained in:
parent
65002511e9
commit
cafd113a3b
4 changed files with 27 additions and 8 deletions
|
|
@ -109,6 +109,7 @@ impl TryFrom<Background> for Video {
|
|||
let settings = gst_video::VideoSettings {
|
||||
mute: true,
|
||||
framerate: 30,
|
||||
appsink_name: "lumina_video".to_string(),
|
||||
};
|
||||
gst_video::create_video(url, &settings)
|
||||
.map_err(|_| ParseError::BackgroundNotVideo)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use url::Url;
|
|||
pub struct VideoSettings {
|
||||
pub mute: bool,
|
||||
pub framerate: u16,
|
||||
pub appsink_name: String,
|
||||
}
|
||||
|
||||
type Result<T> = std::result::Result<T, VideoError>;
|
||||
|
|
@ -26,10 +27,11 @@ pub fn create_video(url: &Url, settings: &VideoSettings) -> Result<Video> {
|
|||
gst::init().map_err(VideoError::GlibError)?;
|
||||
|
||||
let pipeline = format!(
|
||||
r#"playbin uri="{0}" video-sink="videoscale ! videoconvert ! videoflip method=automatic ! videorate ! appsink name=lumina_video drop=true caps=video/x-raw,format=NV12,framerate={1}/1,pixel-aspect-ratio=1/1{2}""#,
|
||||
r#"playbin uri="{0}" video-sink="videoscale ! videoconvert ! videoflip method=automatic ! videorate ! appsink name={1} drop=true caps=video/x-raw,format=NV12,framerate={2}/1,pixel-aspect-ratio=1/1{3}""#,
|
||||
url.as_str(),
|
||||
settings.appsink_name,
|
||||
settings.framerate,
|
||||
if settings.mute { " mute=true" } else { "" },
|
||||
if settings.mute { ",mute=true" } else { "" },
|
||||
);
|
||||
|
||||
let pipeline =
|
||||
|
|
@ -52,9 +54,10 @@ pub fn create_video(url: &Url, settings: &VideoSettings) -> Result<Video> {
|
|||
})?
|
||||
.downcast::<gst::Bin>()
|
||||
.map_err(|_| VideoError::IcedVideoError(iced_video_player::Error::Cast))?;
|
||||
let video_sink = bin.by_name("lumina_video").ok_or_else(|| {
|
||||
VideoError::IcedVideoError(iced_video_player::Error::AppSink(String::from(
|
||||
"Can't find element lumina_video",
|
||||
let video_sink = bin.by_name(&settings.appsink_name).ok_or_else(|| {
|
||||
VideoError::IcedVideoError(iced_video_player::Error::AppSink(format!(
|
||||
"Can't find element {}",
|
||||
settings.appsink_name
|
||||
)))
|
||||
})?;
|
||||
let video_sink = video_sink
|
||||
|
|
|
|||
|
|
@ -126,7 +126,11 @@ impl Presenter {
|
|||
"There should be a video file here",
|
||||
);
|
||||
|
||||
let video_settings = VideoSettings { mute: true, framerate: 15 };
|
||||
let video_settings = VideoSettings {
|
||||
mute: true,
|
||||
framerate: 15,
|
||||
appsink_name: "lumina_preview".to_string(),
|
||||
};
|
||||
let result = gst_video::create_video(&url, &video_settings);
|
||||
match result {
|
||||
Ok(mut v) => {
|
||||
|
|
@ -155,7 +159,13 @@ impl Presenter {
|
|||
"There should be a video file here",
|
||||
);
|
||||
|
||||
let video_settings = VideoSettings { mute: false, framerate: 60 };
|
||||
let video_settings = VideoSettings {
|
||||
mute: false,
|
||||
framerate: 60,
|
||||
appsink_name: "lumina_video".to_string(),
|
||||
|
||||
};
|
||||
|
||||
let result = gst_video::create_video(&url, &video_settings);
|
||||
match result {
|
||||
Ok(mut v) => {
|
||||
|
|
@ -373,6 +383,7 @@ impl Presenter {
|
|||
if let Some(video) = &mut self.preview_video {
|
||||
video.set_paused(false);
|
||||
video.set_looping(self.current_slide.video_loop());
|
||||
debug!(?video);
|
||||
}
|
||||
if let Some(video) = &mut self.presentation_video {
|
||||
video.set_paused(false);
|
||||
|
|
@ -769,12 +780,14 @@ impl Presenter {
|
|||
|
||||
let video_settings = VideoSettings {
|
||||
mute: true,
|
||||
framerate: 15,
|
||||
framerate: 30,
|
||||
appsink_name: "lumina_preview".to_string(),
|
||||
};
|
||||
match gst_video::create_video(&url, &video_settings) {
|
||||
Ok(mut v) => {
|
||||
v.set_looping(self.current_slide.video_loop());
|
||||
v.set_muted(true);
|
||||
debug!(?v);
|
||||
self.preview_video = Some(v);
|
||||
}
|
||||
Err(e) => {
|
||||
|
|
@ -785,6 +798,7 @@ impl Presenter {
|
|||
let video_settings = VideoSettings {
|
||||
mute: false,
|
||||
framerate: 60,
|
||||
appsink_name: "lumina_video".to_string(),
|
||||
};
|
||||
match gst_video::create_video(&url, &video_settings) {
|
||||
Ok(mut v) => {
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ impl VideoEditor {
|
|||
let settings = gst_video::VideoSettings {
|
||||
mute: false,
|
||||
framerate: 60,
|
||||
appsink_name: "lumina_video".to_string(),
|
||||
};
|
||||
|
||||
let Ok(mut player_video) = gst_video::create_video(&url, &settings) else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue