Struct re_video::demux::VideoData

source ·
pub struct VideoData {
    pub config: Config,
    pub timescale: Timescale,
    pub duration: Time,
    pub gops: Vec<GroupOfPictures>,
    pub samples: Vec<Sample>,
    pub samples_statistics: SamplesStatistics,
    pub mp4_tracks: BTreeMap<TrackId, Option<TrackKind>>,
}
Expand description

Decoded video data.

Fields§

§config: Config§timescale: Timescale

How many time units are there per second.

§duration: Time

Duration of the video, in time units.

§gops: Vec<GroupOfPictures>

We split video into GOPs, each beginning with a key frame, followed by any number of delta frames.

§samples: Vec<Sample>

Samples contain the byte offsets into data for each frame.

This list is sorted in ascending order of decode timestamps.

Samples must be decoded in decode-timestamp order, and should be presented in composition-timestamp order.

In MP4, one sample is one frame.

§samples_statistics: SamplesStatistics

Meta information about the samples.

§mp4_tracks: BTreeMap<TrackId, Option<TrackKind>>

All the tracks in the mp4; not just the video track.

Can be nice to show in a UI.

Implementations§

source§

impl VideoData

source

pub fn load_mp4(bytes: &[u8]) -> Result<Self, VideoLoadError>

source§

impl VideoData

source

pub fn load_from_bytes( data: &[u8], media_type: &str ) -> Result<Self, VideoLoadError>

Loads a video from the given data.

TODO(andreas, jan): This should not copy the data, but instead store slices into a shared buffer. at the very least the should be a way to extract only metadata.

source

pub fn duration(&self) -> Duration

Length of the video.

source

pub fn dimensions(&self) -> [u32; 2]

Natural width and height of the video

source

pub fn width(&self) -> u32

Natural width of the video.

source

pub fn height(&self) -> u32

Natural height of the video.

source

pub fn human_readable_codec_string(&self) -> String

The codec used to encode the video.

source

pub fn num_samples(&self) -> usize

The number of samples in the video.

source

pub fn subsampling_mode(&self) -> Option<ChromaSubsamplingModes>

Returns the subsampling mode of the video.

Returns None if not detected or unknown.

source

pub fn bit_depth(&self) -> Option<u8>

Per color component bit depth.

Usually 8, but 10 for HDR (for example).

source

pub fn is_monochrome(&self) -> Option<bool>

Returns None if the mp4 doesn’t specify whether the video is monochrome or we haven’t yet implemented the logic to determine this.

source

pub fn frame_timestamps_ns(&self) -> impl Iterator<Item = i64> + '_

Determines the video timestamps of all frames inside a video, returning raw time values.

Returned timestamps are in nanoseconds since start and are guaranteed to be monotonically increasing.

source

fn latest_sample_index_at_decode_timestamp( samples: &[Sample], decode_time: Time ) -> Option<usize>

For a given decode (!) timestamp, returns the index of the first sample whose decode timestamp is lesser than or equal to the given timestamp.

source

fn latest_sample_index_at_presentation_timestamp_internal( samples: &[Sample], sample_statistics: &SamplesStatistics, presentation_timestamp: Time ) -> Option<usize>

See Self::latest_sample_index_at_presentation_timestamp, split out for testing purposes.

source

pub fn latest_sample_index_at_presentation_timestamp( &self, presentation_timestamp: Time ) -> Option<usize>

For a given presentation timestamp, return the index of the first sample whose presentation timestamp is lesser than or equal to the given timestamp.

Remember that samples after (i.e. with higher index) may have a lower presentation time if the stream has sample reordering!

source

pub fn gop_index_containing_decode_timestamp( &self, decode_time: Time ) -> Option<usize>

For a given decode (!) timestamp, return the index of the group of pictures (GOP) index containing the given timestamp.

source

pub fn gop_index_containing_presentation_timestamp( &self, presentation_timestamp: Time ) -> Option<usize>

For a given presentation timestamp, return the index of the group of pictures (GOP) index containing the given timestamp.

Trait Implementations§

source§

impl Clone for VideoData

source§

fn clone(&self) -> VideoData

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for VideoData

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<T> To for T
where T: ?Sized,

§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more