force format=NV12
This commit is contained in:
parent
9d60f260b0
commit
a7ed9170dd
1 changed files with 6 additions and 7 deletions
13
src/video.rs
13
src/video.rs
|
@ -113,13 +113,13 @@ impl Video {
|
||||||
/// Create a new video player from a given video which loads from `uri`.
|
/// Create a new video player from a given video which loads from `uri`.
|
||||||
/// Note that live sourced will report the duration to be zero.
|
/// Note that live sourced will report the duration to be zero.
|
||||||
pub fn new(uri: &url::Url) -> Result<Self, Error> {
|
pub fn new(uri: &url::Url) -> Result<Self, Error> {
|
||||||
let pipeline = format!("uridecodebin uri=\"{}\" ! videoconvert ! videoscale ! appsink name=iced_video caps=video/x-raw,pixel-aspect-ratio=1/1", uri.as_str());
|
let pipeline = format!("uridecodebin uri=\"{}\" ! videoconvert ! videoscale ! appsink name=iced_video caps=video/x-raw,format=NV12,pixel-aspect-ratio=1/1", uri.as_str());
|
||||||
Self::from_pipeline(pipeline, None)
|
Self::from_pipeline(pipeline, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new video based on GStreamer pipeline in a same format as used in gst-launch-1.0.
|
/// Creates a new video based on GStreamer pipeline in a same format as used in gst-launch-1.0.
|
||||||
/// Expects an appsink plugin to be present with name set to `iced_video` and caps to
|
/// Expects an appsink plugin to be present with name set to `iced_video` and caps to
|
||||||
/// `video/x-raw,pixel-aspect-ratio=1/1`
|
/// `video/x-raw,format=NV12,pixel-aspect-ratio=1/1`
|
||||||
pub fn from_pipeline<S: AsRef<str>>(pipeline: S, is_live: Option<bool>) -> Result<Self, Error> {
|
pub fn from_pipeline<S: AsRef<str>>(pipeline: S, is_live: Option<bool>) -> Result<Self, Error> {
|
||||||
gst::init()?;
|
gst::init()?;
|
||||||
let pipeline = gst::parse::launch(pipeline.as_ref())?
|
let pipeline = gst::parse::launch(pipeline.as_ref())?
|
||||||
|
@ -131,7 +131,7 @@ impl Video {
|
||||||
|
|
||||||
/// Creates a new video based on GStreamer pipeline.
|
/// Creates a new video based on GStreamer pipeline.
|
||||||
/// Expects an appsink plugin to be present with name set to `iced_video` and caps to
|
/// Expects an appsink plugin to be present with name set to `iced_video` and caps to
|
||||||
/// `video/x-raw,pixel-aspect-ratio=1/1`
|
/// `video/x-raw,format=NV12,pixel-aspect-ratio=1/1`
|
||||||
pub fn from_gst_pipeline(
|
pub fn from_gst_pipeline(
|
||||||
pipeline: gst::Pipeline,
|
pipeline: gst::Pipeline,
|
||||||
is_live: Option<bool>,
|
is_live: Option<bool>,
|
||||||
|
@ -209,10 +209,9 @@ impl Video {
|
||||||
let buffer = sample.buffer().ok_or(gst::FlowError::Error)?;
|
let buffer = sample.buffer().ok_or(gst::FlowError::Error)?;
|
||||||
let map = buffer.map_readable().map_err(|_| gst::FlowError::Error)?;
|
let map = buffer.map_readable().map_err(|_| gst::FlowError::Error)?;
|
||||||
|
|
||||||
frame_ref
|
let mut frame_ref = frame_ref.lock().map_err(|_| gst::FlowError::Error)?;
|
||||||
.lock()
|
let frame_len = frame_ref.len();
|
||||||
.map_err(|_| gst::FlowError::Error)?
|
frame_ref.copy_from_slice(&map.as_slice()[..frame_len]);
|
||||||
.copy_from_slice(map.as_slice());
|
|
||||||
|
|
||||||
upload_frame_ref.store(true, Ordering::SeqCst);
|
upload_frame_ref.store(true, Ordering::SeqCst);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue