Skip to main content

H264Source

Struct H264Source 

Source
pub struct H264Source<H: SeekableH264Source> {
    pub h264_metadata: Option<H264Metadata>,
    /* private fields */
}
Expand description

H264 data source. Can come directly from an “Annex B” format .h264 file or from an MP4 file.

This should be as general purpose H264 file reader as possible.

Strand Camera specific features are supported if present: metadata at the H264 stream start (UUID 0ba99cc7-f607-3851-b35e-8c7d8c04da0a) is parsed, as are precision time stamps (specified by MISB ST 0604.3).

§Timestamp handling:

§Case 1, H264 in MP4

Tracks in MP4 files are composed of samples. Each sample has a presentation timestamp (PTS), the time elapsed from the start. A sample contains multiple (0, 1, 2 or more) H264 NAL units. A sample can contain zero, one, two or more image frames of data. (There exist MP4 files in which a sample contains zero NAL units and thus zero image frames as well as MP4 files in which a single sample contains many NAL units and many image frames.) Samples also carry a duration, which is informational to assist with playback. The duration of frame N should be the PTS of frame N+1 - the PTS of frame N. There seems to be a general assumption that samples should be equi-distant in time and thus that the file has a constant frame rate, although I have not found this in any specification.

§Case 2, raw H264

A raw .h264 file, which is defined as the “Annex B format”, (or simply the H264 data inside an MP4 file) may have no explicit timing information in it. Alternatively, for example with the timing_info_present_flag in the VUI parameters, timing information may be present. So far we ignore these flags. In this case, the timestamp data for the frame is simply returned as a fraction of complete (in the interval from 0.0 to 1.0).

§Case 3, H264 files with MISPmicrosectime supplemental enhancement information

H264 can contain additional NAL units, called supplemental enhancement information (SEI) which is ignored by decoders but can provide additional information such as metadata at the start of H264 data and per-frame timestamps as specified in MISB ST 0604.3.

Fields§

§h264_metadata: Option<H264Metadata>

Implementations§

Source§

impl<H: SeekableH264Source> H264Source<H>

Source

pub fn as_seekable_h264_source(&self) -> &H

Source

pub fn mp4_sample_timing(&self) -> Option<&[Mp4SampleTiming]>

Per-sample timing (decode duration + composition offset) for MP4 sources, indexed by frame number (see FrameData::idx). None for non-MP4 sources.

Source

pub fn srt_truncation(&self) -> Option<&SrtTruncation>

Set when an SRT-file timestamp source ran out of usable stanzas before covering every frame in the container; None otherwise.

Trait Implementations§

Source§

impl<H: SeekableH264Source> FrameDataSource for H264Source<H>

Source§

fn width(&self) -> u32

Get the width of the source images, in pixels.
Source§

fn height(&self) -> u32

Get the height of the source images, in pixels.
Source§

fn camera_name(&self) -> Option<&str>

Source§

fn gamma(&self) -> Option<f32>

Source§

fn frame0_time(&self) -> Option<DateTime<FixedOffset>>

Get the timestamp of the first frame. Read more
Source§

fn average_framerate(&self) -> Option<f64>

Get the average framerate Read more
Source§

fn skip_n_frames(&mut self, n_frames: usize) -> Result<()>

Set source to skip the first N frames. Read more
Source§

fn estimate_luminance_range(&mut self) -> Result<(u16, u16)>

Scan over the input images and estimate the luminance range Read more
Source§

fn decode_order_iter<'a>( &'a mut self, ) -> Box<dyn Iterator<Item = Result<FrameData>> + 'a>

Get an iterator over all frames in decode order (the order samples are stored in the stream). Read more
Source§

fn presentation_order_iter<'a>( &'a mut self, ) -> Result<Box<dyn Iterator<Item = Result<FrameData>> + 'a>>

Get an iterator over all frames in presentation (display) order, with monotonically non-decreasing timestamps. Read more
Source§

fn timestamp_source(&self) -> &str

A string describing the source of the timestamp data
Source§

fn has_timestamps(&self) -> bool

Whether timestamps are available. Read more
Source§

fn srt_truncation(&self) -> Option<SrtTruncation>

Set when an SRT-file timestamp source ran out of usable stanzas before covering every frame in the container, in which case the source was truncated to the last complete group of pictures a stanza is available for every frame of. None for sources not using an SRT file, or when the SRT covered every frame.

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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
Source§

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

Source§

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>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,