FFmpeg  4.2.2
Data Fields
AVStream Struct Reference

Stream structure. More...

#include <libavformat/avformat.h>

Data Fields

int index
 stream index in AVFormatContext More...
 
int id
 Format-specific stream ID. More...
 
void * priv_data
 
AVRational time_base
 This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented. More...
 
int64_t start_time
 Decoding: pts of the first frame of the stream in presentation order, in stream time base. More...
 
int64_t duration
 Decoding: duration of the stream, in stream time base. More...
 
int64_t nb_frames
 number of frames in this stream if known or 0 More...
 
int disposition
 AV_DISPOSITION_* bit field. More...
 
enum AVDiscard discard
 Selects which packets can be discarded at will and do not need to be demuxed. More...
 
AVRational sample_aspect_ratio
 sample aspect ratio (0 if unknown) More...
 
AVDictionarymetadata
 
AVRational avg_frame_rate
 Average framerate. More...
 
AVPacket attached_pic
 For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached picture. More...
 
AVPacketSideDataside_data
 An array of side data that applies to the whole stream (i.e. More...
 
int nb_side_data
 The number of elements in the AVStream.side_data array. More...
 
int event_flags
 Flags for the user to detect events happening on the stream. More...
 
AVRational r_frame_rate
 Real base framerate of the stream. More...
 
AVCodecParameterscodecpar
 Codec parameters associated with this stream. More...
 
struct {
   int64_t   last_dts
 
   int64_t   duration_gcd
 
   int   duration_count
 
   int64_t   rfps_duration_sum
 
   double(*   duration_error )[2][MAX_STD_TIMEBASES]
 
   int64_t   codec_info_duration
 
   int64_t   codec_info_duration_fields
 
   int   frame_delay_evidence
 
   int   found_decoder
 0 -> decoder has not been searched for yet. More...
 
   int64_t   last_duration
 
   int64_t   fps_first_dts
 Those are used for average framerate estimation. More...
 
   int   fps_first_dts_idx
 
   int64_t   fps_last_dts
 
   int   fps_last_dts_idx
 
} * info
 Stream information used internally by avformat_find_stream_info() More...
 
int pts_wrap_bits
 number of bits in pts (used for wrapping control) More...
 
int64_t first_dts
 Timestamp corresponding to the last dts sync point. More...
 
int64_t cur_dts
 
int64_t last_IP_pts
 
int last_IP_duration
 
int probe_packets
 Number of packets to buffer for codec probing. More...
 
int codec_info_nb_frames
 Number of frames that have been demuxed during avformat_find_stream_info() More...
 
enum AVStreamParseType need_parsing
 
struct AVCodecParserContextparser
 
struct AVPacketListlast_in_packet_buffer
 last packet in packet_buffer for this stream when muxing. More...
 
AVProbeData probe_data
 
int64_t pts_buffer [MAX_REORDER_DELAY+1]
 
AVIndexEntryindex_entries
 Only used if the format does not support seeking natively. More...
 
int nb_index_entries
 
unsigned int index_entries_allocated_size
 
int stream_identifier
 Stream Identifier This is the MPEG-TS stream identifier +1 0 means unknown. More...
 
int program_num
 Details of the MPEG-TS program which created this stream. More...
 
int pmt_version
 
int pmt_stream_idx
 
int64_t interleaver_chunk_size
 
int64_t interleaver_chunk_duration
 
int request_probe
 stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with request_probe being the minimum score to accept. More...
 
int skip_to_keyframe
 Indicates that everything up to the next keyframe should be discarded. More...
 
int skip_samples
 Number of samples to skip at the start of the frame decoded from the next packet. More...
 
int64_t start_skip_samples
 If not 0, the number of samples that should be skipped from the start of the stream (the samples are removed from packets with pts==0, which also assumes negative timestamps do not happen). More...
 
int64_t first_discard_sample
 If not 0, the first audio sample that should be discarded from the stream. More...
 
int64_t last_discard_sample
 The sample after last sample that is intended to be discarded after first_discard_sample. More...
 
int nb_decoded_frames
 Number of internally decoded frames, used internally in libavformat, do not access its lifetime differs from info which is why it is not in that structure. More...
 
int64_t mux_ts_offset
 Timestamp offset added to timestamps before muxing NOT PART OF PUBLIC API. More...
 
int64_t pts_wrap_reference
 Internal data to check for wrapping of the time stamp. More...
 
int pts_wrap_behavior
 Options for behavior, when a wrap is detected. More...
 
int update_initial_durations_done
 Internal data to prevent doing update_initial_durations() twice. More...
 
int64_t pts_reorder_error [MAX_REORDER_DELAY+1]
 Internal data to generate dts from pts. More...
 
uint8_t pts_reorder_error_count [MAX_REORDER_DELAY+1]
 
int64_t last_dts_for_order_check
 Internal data to analyze DTS and detect faulty mpeg streams. More...
 
uint8_t dts_ordered
 
uint8_t dts_misordered
 
int inject_global_side_data
 Internal data to inject global side data. More...
 
AVRational display_aspect_ratio
 display aspect ratio (0 if unknown) More...
 
AVStreamInternalinternal
 An opaque field for libavformat internal usage. More...
 

Detailed Description

Stream structure.

New fields can be added to the end with minor version bumps. Removal, reordering and changes to existing fields require a major version bump. sizeof(AVStream) must not be used outside libav*.

Examples:
demuxing_decoding.c, hw_decode.c, muxing.c, remuxing.c, transcode_aac.c, and transcoding.c.

Definition at line 881 of file avformat.h.

Field Documentation

◆ index

int AVStream::index

stream index in AVFormatContext

Examples:
muxing.c.

Definition at line 882 of file avformat.h.

Referenced by write_frame().

◆ id

int AVStream::id

Format-specific stream ID.

decoding: set by libavformat encoding: set by the user, replaced by libavformat if left unset

Examples:
muxing.c.

Definition at line 888 of file avformat.h.

Referenced by add_stream().

◆ priv_data

void* AVStream::priv_data

Definition at line 896 of file avformat.h.

◆ time_base

AVRational AVStream::time_base

This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.

decoding: set by libavformat encoding: May be set by the caller before avformat_write_header() to provide a hint to the muxer about the desired timebase. In avformat_write_header(), the muxer will overwrite this field with the timebase that will actually be used for the timestamps written into the file (which may or may not be related to the user-provided one, depending on the format).

Examples:
filtering_audio.c, filtering_video.c, muxing.c, remuxing.c, transcode_aac.c, and transcoding.c.

Definition at line 910 of file avformat.h.

Referenced by add_stream(), encode_write_frame(), init_filters(), log_packet(), main(), open_output_file(), and write_frame().

◆ start_time

int64_t AVStream::start_time

Decoding: pts of the first frame of the stream in presentation order, in stream time base.

Only set this if you are absolutely 100% sure that the value you set it to really is the pts of the first frame. This may be undefined (AV_NOPTS_VALUE).

Note
The ASF header does NOT contain a correct start_time the ASF demuxer must NOT set this.

Definition at line 920 of file avformat.h.

◆ duration

int64_t AVStream::duration

Decoding: duration of the stream, in stream time base.

If a source file does not specify a duration, but does specify a bitrate, this value will be estimated from bitrate and file size.

Encoding: May be set by the caller before avformat_write_header() to provide a hint to the muxer about the estimated duration.

Definition at line 930 of file avformat.h.

◆ nb_frames

int64_t AVStream::nb_frames

number of frames in this stream if known or 0

Definition at line 932 of file avformat.h.

◆ disposition

int AVStream::disposition

AV_DISPOSITION_* bit field.

Definition at line 934 of file avformat.h.

◆ discard

enum AVDiscard AVStream::discard

Selects which packets can be discarded at will and do not need to be demuxed.

Definition at line 936 of file avformat.h.

◆ sample_aspect_ratio

AVRational AVStream::sample_aspect_ratio

sample aspect ratio (0 if unknown)

  • encoding: Set by user.
  • decoding: Set by libavformat.

Definition at line 943 of file avformat.h.

◆ metadata

AVDictionary* AVStream::metadata

Definition at line 945 of file avformat.h.

◆ avg_frame_rate

AVRational AVStream::avg_frame_rate

Average framerate.

Definition at line 954 of file avformat.h.

◆ attached_pic

AVPacket AVStream::attached_pic

For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached picture.

decoding: set by libavformat, must not be modified by the caller. encoding: unused

Definition at line 963 of file avformat.h.

◆ side_data

AVPacketSideData* AVStream::side_data

An array of side data that applies to the whole stream (i.e.

the container does not allow it to change between packets).

There may be no overlap between the side data in this array and side data in the packets. I.e. a given side data is either exported by the muxer (demuxing) / set by the caller (muxing) in this array, then it never appears in the packets, or the side data is exported / sent through the packets (always in the first packet where the value becomes known or changes), then it does not appear in this array.

  • demuxing: Set by libavformat when the stream is created.
  • muxing: May be set by the caller before avformat_write_header().

Freed by libavformat in avformat_free_context().

See also
av_format_inject_global_side_data()

Definition at line 983 of file avformat.h.

◆ nb_side_data

int AVStream::nb_side_data

The number of elements in the AVStream.side_data array.

Definition at line 987 of file avformat.h.

◆ event_flags

int AVStream::event_flags

Flags for the user to detect events happening on the stream.

Flags must be cleared by the user once the event has been handled. A combination of AVSTREAM_EVENT_FLAG_*.

Definition at line 994 of file avformat.h.

◆ r_frame_rate

AVRational AVStream::r_frame_rate

Real base framerate of the stream.

This is the lowest framerate with which all timestamps can be represented accurately (it is the least common multiple of all framerates in the stream). Note, this value is just a guess! For example, if the time base is 1/90000 and all frames have either approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.

Definition at line 1005 of file avformat.h.

◆ codecpar

AVCodecParameters* AVStream::codecpar

Codec parameters associated with this stream.

Allocated and freed by libavformat in avformat_new_stream() and avformat_free_context() respectively.

Examples:
demuxing_decoding.c, filtering_audio.c, filtering_video.c, hw_decode.c, muxing.c, remuxing.c, transcode_aac.c, and transcoding.c.

Definition at line 1028 of file avformat.h.

Referenced by encode_write_frame(), init_filters(), main(), open_audio(), open_codec_context(), open_input_file(), open_output_file(), and open_video().

◆ last_dts

int64_t AVStream::last_dts

Definition at line 1045 of file avformat.h.

◆ duration_gcd

int64_t AVStream::duration_gcd

Definition at line 1046 of file avformat.h.

◆ duration_count

int AVStream::duration_count

Definition at line 1047 of file avformat.h.

◆ rfps_duration_sum

int64_t AVStream::rfps_duration_sum

Definition at line 1048 of file avformat.h.

◆ duration_error

double(* AVStream::duration_error)[2][MAX_STD_TIMEBASES]

Definition at line 1049 of file avformat.h.

◆ codec_info_duration

int64_t AVStream::codec_info_duration

Definition at line 1050 of file avformat.h.

◆ codec_info_duration_fields

int64_t AVStream::codec_info_duration_fields

Definition at line 1051 of file avformat.h.

◆ frame_delay_evidence

int AVStream::frame_delay_evidence

Definition at line 1052 of file avformat.h.

◆ found_decoder

int AVStream::found_decoder

0 -> decoder has not been searched for yet.

>0 -> decoder found <0 -> decoder with codec_id == -found_decoder has not been found

Definition at line 1059 of file avformat.h.

◆ last_duration

int64_t AVStream::last_duration

Definition at line 1061 of file avformat.h.

◆ fps_first_dts

int64_t AVStream::fps_first_dts

Those are used for average framerate estimation.

Definition at line 1066 of file avformat.h.

◆ fps_first_dts_idx

int AVStream::fps_first_dts_idx

Definition at line 1067 of file avformat.h.

◆ fps_last_dts

int64_t AVStream::fps_last_dts

Definition at line 1068 of file avformat.h.

◆ fps_last_dts_idx

int AVStream::fps_last_dts_idx

Definition at line 1069 of file avformat.h.

◆ info

struct { ... } * AVStream::info

Stream information used internally by avformat_find_stream_info()

◆ pts_wrap_bits

int AVStream::pts_wrap_bits

number of bits in pts (used for wrapping control)

Definition at line 1073 of file avformat.h.

◆ first_dts

int64_t AVStream::first_dts

Timestamp corresponding to the last dts sync point.

Initialized when AVCodecParserContext.dts_sync_point >= 0 and a DTS is received from the underlying container. Otherwise set to AV_NOPTS_VALUE by default.

Definition at line 1083 of file avformat.h.

◆ cur_dts

int64_t AVStream::cur_dts

Definition at line 1084 of file avformat.h.

◆ last_IP_pts

int64_t AVStream::last_IP_pts

Definition at line 1085 of file avformat.h.

◆ last_IP_duration

int AVStream::last_IP_duration

Definition at line 1086 of file avformat.h.

◆ probe_packets

int AVStream::probe_packets

Number of packets to buffer for codec probing.

Definition at line 1091 of file avformat.h.

◆ codec_info_nb_frames

int AVStream::codec_info_nb_frames

Number of frames that have been demuxed during avformat_find_stream_info()

Definition at line 1096 of file avformat.h.

◆ need_parsing

enum AVStreamParseType AVStream::need_parsing

Definition at line 1099 of file avformat.h.

◆ parser

struct AVCodecParserContext* AVStream::parser

Definition at line 1100 of file avformat.h.

◆ last_in_packet_buffer

struct AVPacketList* AVStream::last_in_packet_buffer

last packet in packet_buffer for this stream when muxing.

Definition at line 1105 of file avformat.h.

◆ probe_data

AVProbeData AVStream::probe_data

Definition at line 1106 of file avformat.h.

◆ pts_buffer

int64_t AVStream::pts_buffer[MAX_REORDER_DELAY+1]

Definition at line 1108 of file avformat.h.

◆ index_entries

AVIndexEntry* AVStream::index_entries

Only used if the format does not support seeking natively.

Definition at line 1110 of file avformat.h.

◆ nb_index_entries

int AVStream::nb_index_entries

Definition at line 1112 of file avformat.h.

◆ index_entries_allocated_size

unsigned int AVStream::index_entries_allocated_size

Definition at line 1113 of file avformat.h.

◆ stream_identifier

int AVStream::stream_identifier

Stream Identifier This is the MPEG-TS stream identifier +1 0 means unknown.

Definition at line 1120 of file avformat.h.

◆ program_num

int AVStream::program_num

Details of the MPEG-TS program which created this stream.

Definition at line 1125 of file avformat.h.

◆ pmt_version

int AVStream::pmt_version

Definition at line 1126 of file avformat.h.

◆ pmt_stream_idx

int AVStream::pmt_stream_idx

Definition at line 1127 of file avformat.h.

◆ interleaver_chunk_size

int64_t AVStream::interleaver_chunk_size

Definition at line 1129 of file avformat.h.

◆ interleaver_chunk_duration

int64_t AVStream::interleaver_chunk_duration

Definition at line 1130 of file avformat.h.

◆ request_probe

int AVStream::request_probe

stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with request_probe being the minimum score to accept.

NOT PART OF PUBLIC API

Definition at line 1139 of file avformat.h.

◆ skip_to_keyframe

int AVStream::skip_to_keyframe

Indicates that everything up to the next keyframe should be discarded.

Definition at line 1144 of file avformat.h.

◆ skip_samples

int AVStream::skip_samples

Number of samples to skip at the start of the frame decoded from the next packet.

Definition at line 1149 of file avformat.h.

◆ start_skip_samples

int64_t AVStream::start_skip_samples

If not 0, the number of samples that should be skipped from the start of the stream (the samples are removed from packets with pts==0, which also assumes negative timestamps do not happen).

Intended for use with formats such as mp3 with ad-hoc gapless audio support.

Definition at line 1158 of file avformat.h.

◆ first_discard_sample

int64_t AVStream::first_discard_sample

If not 0, the first audio sample that should be discarded from the stream.

This is broken by design (needs global sample count), but can't be avoided for broken by design formats such as mp3 with ad-hoc gapless audio support.

Definition at line 1166 of file avformat.h.

◆ last_discard_sample

int64_t AVStream::last_discard_sample

The sample after last sample that is intended to be discarded after first_discard_sample.

Works on frame boundaries only. Used to prevent early EOF if the gapless info is broken (considered concatenated mp3s).

Definition at line 1173 of file avformat.h.

◆ nb_decoded_frames

int AVStream::nb_decoded_frames

Number of internally decoded frames, used internally in libavformat, do not access its lifetime differs from info which is why it is not in that structure.

Definition at line 1179 of file avformat.h.

◆ mux_ts_offset

int64_t AVStream::mux_ts_offset

Timestamp offset added to timestamps before muxing NOT PART OF PUBLIC API.

Definition at line 1185 of file avformat.h.

◆ pts_wrap_reference

int64_t AVStream::pts_wrap_reference

Internal data to check for wrapping of the time stamp.

Definition at line 1190 of file avformat.h.

◆ pts_wrap_behavior

int AVStream::pts_wrap_behavior

Options for behavior, when a wrap is detected.

Defined by AV_PTS_WRAP_ values.

If correction is enabled, there are two possibilities: If the first time stamp is near the wrap point, the wrap offset will be subtracted, which will create negative time stamps. Otherwise the offset will be added.

Definition at line 1202 of file avformat.h.

◆ update_initial_durations_done

int AVStream::update_initial_durations_done

Internal data to prevent doing update_initial_durations() twice.

Definition at line 1207 of file avformat.h.

◆ pts_reorder_error

int64_t AVStream::pts_reorder_error[MAX_REORDER_DELAY+1]

Internal data to generate dts from pts.

Definition at line 1212 of file avformat.h.

◆ pts_reorder_error_count

uint8_t AVStream::pts_reorder_error_count[MAX_REORDER_DELAY+1]

Definition at line 1213 of file avformat.h.

◆ last_dts_for_order_check

int64_t AVStream::last_dts_for_order_check

Internal data to analyze DTS and detect faulty mpeg streams.

Definition at line 1218 of file avformat.h.

◆ dts_ordered

uint8_t AVStream::dts_ordered

Definition at line 1219 of file avformat.h.

◆ dts_misordered

uint8_t AVStream::dts_misordered

Definition at line 1220 of file avformat.h.

◆ inject_global_side_data

int AVStream::inject_global_side_data

Internal data to inject global side data.

Definition at line 1225 of file avformat.h.

◆ display_aspect_ratio

AVRational AVStream::display_aspect_ratio

display aspect ratio (0 if unknown)

  • encoding: unused
  • decoding: Set by libavformat to calculate sample_aspect_ratio internally

Definition at line 1232 of file avformat.h.

◆ internal

AVStreamInternal* AVStream::internal

An opaque field for libavformat internal usage.

Must not be accessed in any way by callers.

Definition at line 1238 of file avformat.h.


The documentation for this struct was generated from the following file: