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
impl VideoData
sourcepub fn load_from_bytes(
data: &[u8],
media_type: &str
) -> Result<Self, VideoLoadError>
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.
sourcepub fn dimensions(&self) -> [u32; 2]
pub fn dimensions(&self) -> [u32; 2]
Natural width and height of the video
sourcepub fn human_readable_codec_string(&self) -> String
pub fn human_readable_codec_string(&self) -> String
The codec used to encode the video.
sourcepub fn num_samples(&self) -> usize
pub fn num_samples(&self) -> usize
The number of samples in the video.
sourcepub fn subsampling_mode(&self) -> Option<ChromaSubsamplingModes>
pub fn subsampling_mode(&self) -> Option<ChromaSubsamplingModes>
Returns the subsampling mode of the video.
Returns None if not detected or unknown.
sourcepub fn bit_depth(&self) -> Option<u8>
pub fn bit_depth(&self) -> Option<u8>
Per color component bit depth.
Usually 8, but 10 for HDR (for example).
sourcepub fn is_monochrome(&self) -> Option<bool>
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.
sourcepub fn frame_timestamps_ns(&self) -> impl Iterator<Item = i64> + '_
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.
sourcefn latest_sample_index_at_decode_timestamp(
samples: &[Sample],
decode_time: Time
) -> Option<usize>
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.
sourcefn latest_sample_index_at_presentation_timestamp_internal(
samples: &[Sample],
sample_statistics: &SamplesStatistics,
presentation_timestamp: Time
) -> Option<usize>
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.
sourcepub fn latest_sample_index_at_presentation_timestamp(
&self,
presentation_timestamp: Time
) -> Option<usize>
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!
sourcepub fn gop_index_containing_decode_timestamp(
&self,
decode_time: Time
) -> Option<usize>
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.
sourcepub fn gop_index_containing_presentation_timestamp(
&self,
presentation_timestamp: Time
) -> Option<usize>
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§
Auto Trait Implementations§
impl Freeze for VideoData
impl RefUnwindSafe for VideoData
impl Send for VideoData
impl Sync for VideoData
impl Unpin for VideoData
impl UnwindSafe for VideoData
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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