FFmpeg
Data Structures | Macros | Enumerations | Functions
mux.h File Reference
#include <stdint.h>
#include "libavcodec/packet.h"
#include "avformat.h"

Go to the source code of this file.

Data Structures

struct  FFOutputFormat
 

Macros

#define FF_OFMT_FLAG_ALLOW_FLUSH   (1 << 1)
 This flag indicates that the muxer stores data internally and supports flushing it. More...
 
#define FF_OFMT_FLAG_MAX_ONE_OF_EACH   (1 << 2)
 If this flag is set, it indicates that for each codec type whose corresponding default codec (i.e. More...
 
#define FF_OFMT_FLAG_ONLY_DEFAULT_CODECS   (1 << 3)
 If this flag is set, then the only permitted audio/video/subtitle codec ids are AVOutputFormat.audio/video/subtitle_codec; if any of the latter is unset (i.e. More...
 

Enumerations

enum  AVWriteUncodedFrameFlags { AV_WRITE_UNCODED_FRAME_QUERY = 0x0001 }
 Flags for AVFormatContext.write_uncoded_frame() More...
 

Functions

static const FFOutputFormatffofmt (const AVOutputFormat *fmt)
 
int ff_interleave_add_packet (AVFormatContext *s, AVPacket *pkt, int(*compare)(AVFormatContext *, const AVPacket *, const AVPacket *))
 Add packet to an AVFormatContext's packet_buffer list, determining its interleaved position using compare() function argument. More...
 
int ff_interleave_packet_per_dts (AVFormatContext *s, AVPacket *pkt, int flush, int has_packet)
 Interleave an AVPacket per dts so it can be muxed. More...
 
int ff_interleave_packet_passthrough (AVFormatContext *s, AVPacket *pkt, int flush, int has_packet)
 Interleave packets directly in the order in which they arrive without any sort of buffering. More...
 
const AVPacketff_interleaved_peek (AVFormatContext *s, int stream)
 Find the next packet in the interleaving queue for the given stream. More...
 
int ff_get_muxer_ts_offset (AVFormatContext *s, int stream_index, int64_t *offset)
 
int ff_stream_add_bitstream_filter (AVStream *st, const char *name, const char *args)
 Add a bitstream filter to a stream. More...
 
int ff_write_chained (AVFormatContext *dst, int dst_stream, AVPacket *pkt, AVFormatContext *src, int interleave)
 Write a packet to another muxer than the one the user originally intended. More...
 
int ff_format_shift_data (AVFormatContext *s, int64_t read_start, int shift_size)
 Make shift_size amount of space at read_start by shifting data in the output at read_start until the current IO position. More...
 
int ff_format_output_open (AVFormatContext *s, const char *url, AVDictionary **options)
 Utility function to open IO stream of output format. More...
 
int ff_parse_creation_time_metadata (AVFormatContext *s, int64_t *timestamp, int return_seconds)
 Parse creation_time in AVFormatContext metadata if exists and warn if the parsing fails. More...
 
int ff_standardize_creation_time (AVFormatContext *s)
 Standardize creation_time metadata in AVFormatContext to an ISO-8601 timestamp string. More...
 

Macro Definition Documentation

◆ FF_OFMT_FLAG_ALLOW_FLUSH

#define FF_OFMT_FLAG_ALLOW_FLUSH   (1 << 1)

This flag indicates that the muxer stores data internally and supports flushing it.

Flushing is signalled by sending a NULL packet to the muxer's write_packet callback; without this flag, a muxer never receives NULL packets. So the documentation of write_packet below for the semantics of the return value in case of flushing.

Definition at line 38 of file mux.h.

◆ FF_OFMT_FLAG_MAX_ONE_OF_EACH

#define FF_OFMT_FLAG_MAX_ONE_OF_EACH   (1 << 2)

If this flag is set, it indicates that for each codec type whose corresponding default codec (i.e.

AVOutputFormat.audio_codec, AVOutputFormat.video_codec and AVOutputFormat.subtitle_codec) is set (i.e. != AV_CODEC_ID_NONE) only one stream of this type can be muxed. It furthermore indicates that no stream with a codec type that has no default codec or whose default codec is AV_CODEC_ID_NONE can be muxed. Both of these restrictions are checked generically before the actual muxer's init/write_header callbacks.

Definition at line 50 of file mux.h.

◆ FF_OFMT_FLAG_ONLY_DEFAULT_CODECS

#define FF_OFMT_FLAG_ONLY_DEFAULT_CODECS   (1 << 3)

If this flag is set, then the only permitted audio/video/subtitle codec ids are AVOutputFormat.audio/video/subtitle_codec; if any of the latter is unset (i.e.

equal to AV_CODEC_ID_NONE), then no stream of the corresponding type is supported. In addition, codec types without default codec field are disallowed.

Definition at line 59 of file mux.h.

Enumeration Type Documentation

◆ AVWriteUncodedFrameFlags

Flags for AVFormatContext.write_uncoded_frame()

Enumerator
AV_WRITE_UNCODED_FRAME_QUERY 

Query whether the feature is possible on this stream.

The frame argument is ignored.

Definition at line 233 of file mux.h.

Function Documentation

◆ ffofmt()

static const FFOutputFormat* ffofmt ( const AVOutputFormat fmt)
inlinestatic

◆ ff_interleave_add_packet()

int ff_interleave_add_packet ( AVFormatContext s,
AVPacket pkt,
int(*)(AVFormatContext *, const AVPacket *, const AVPacket *)  compare 
)

Add packet to an AVFormatContext's packet_buffer list, determining its interleaved position using compare() function argument.

Returns
0 on success, < 0 on error. pkt will always be blank on return.

Definition at line 856 of file mux.c.

Referenced by ff_interleave_packet_per_dts(), gxf_interleave_packet(), and mxf_interleave().

◆ ff_interleave_packet_per_dts()

int ff_interleave_packet_per_dts ( AVFormatContext s,
AVPacket pkt,
int  flush,
int  has_packet 
)

Interleave an AVPacket per dts so it can be muxed.

See the documentation of AVOutputFormat.interleave_packet for details.

Definition at line 960 of file mux.c.

Referenced by gxf_interleave_packet(), and init_muxer().

◆ ff_interleave_packet_passthrough()

int ff_interleave_packet_passthrough ( AVFormatContext s,
AVPacket pkt,
int  flush,
int  has_packet 
)

Interleave packets directly in the order in which they arrive without any sort of buffering.

Definition at line 1081 of file mux.c.

Referenced by init_muxer().

◆ ff_interleaved_peek()

const AVPacket* ff_interleaved_peek ( AVFormatContext s,
int  stream 
)

Find the next packet in the interleaving queue for the given stream.

Returns
a pointer to a packet if one was found, NULL otherwise.

Definition at line 1103 of file mux.c.

Referenced by mov_flush_fragment().

◆ ff_get_muxer_ts_offset()

int ff_get_muxer_ts_offset ( AVFormatContext s,
int  stream_index,
int64_t offset 
)

Definition at line 1087 of file mux.c.

Referenced by mov_flush_fragment().

◆ ff_stream_add_bitstream_filter()

int ff_stream_add_bitstream_filter ( AVStream st,
const char *  name,
const char *  args 
)

Add a bitstream filter to a stream.

Parameters
stoutput stream to add a filter to
namethe name of the filter to add
argsfilter-specific argument string
Returns
>0 on success; AVERROR code on failure

Definition at line 1354 of file mux.c.

Referenced by daud_init(), flv_check_bitstream(), gxf_write_header(), ivf_init(), latm_check_bitstream(), mkv_check_bitstream(), mov_check_bitstream(), mpegts_check_bitstream(), mxf_check_bitstream(), and mxf_init().

◆ ff_write_chained()

int ff_write_chained ( AVFormatContext dst,
int  dst_stream,
AVPacket pkt,
AVFormatContext src,
int  interleave 
)

Write a packet to another muxer than the one the user originally intended.

Useful when chaining muxers, where one muxer internally writes a received packet to another muxer.

Parameters
dstthe muxer to write the packet to
dst_streamthe stream index within dst to write the packet to
pktthe packet to be written. It will be returned blank when av_interleaved_write_frame() is used, unchanged otherwise.
srcthe muxer the packet originally was intended for
interleave0->use av_write_frame, 1->av_interleaved_write_frame
Returns
the value av_write_frame returned

Definition at line 1397 of file mux.c.

Referenced by dash_write_packet(), ff_mov_add_hinted_packet(), hds_write_packet(), hls_write_packet(), ism_write_packet(), rtsp_write_packet(), sap_write_packet(), and seg_write_packet().

◆ ff_format_shift_data()

int ff_format_shift_data ( AVFormatContext s,
int64_t  read_start,
int  shift_size 
)

Make shift_size amount of space at read_start by shifting data in the output at read_start until the current IO position.

The underlying IO context must be seekable.

Definition at line 72 of file mux_utils.c.

Referenced by mkv_write_trailer(), shift_data(), and write_header().

◆ ff_format_output_open()

int ff_format_output_open ( AVFormatContext s,
const char *  url,
AVDictionary **  options 
)

Utility function to open IO stream of output format.

Parameters
sAVFormatContext
urlURL or file name to open for writing @options optional options which will be passed to io_open callback
Returns
>=0 on success, negative AVERROR in case of failure

Definition at line 128 of file mux_utils.c.

Referenced by fifo_thread_write_header(), and open_slave().

◆ ff_parse_creation_time_metadata()

int ff_parse_creation_time_metadata ( AVFormatContext s,
int64_t timestamp,
int  return_seconds 
)

Parse creation_time in AVFormatContext metadata if exists and warn if the parsing fails.

Parameters
sAVFormatContext
timestampparsed timestamp in microseconds, only set on successful parsing
return_secondsset this to get the number of seconds in timestamp instead of microseconds
Returns
1 if OK, 0 if the metadata was not present, AVERROR(EINVAL) on parse error

Definition at line 138 of file mux_utils.c.

Referenced by asf_write_header1(), dv_init_mux(), ff_standardize_creation_time(), gxf_write_umf_material_description(), mkv_write_info(), mov_write_header(), and mxf_init().

◆ ff_standardize_creation_time()

int ff_standardize_creation_time ( AVFormatContext s)

Standardize creation_time metadata in AVFormatContext to an ISO-8601 timestamp string.

Parameters
sAVFormatContext
Returns
<0 on error

Definition at line 155 of file mux_utils.c.

Referenced by caf_write_header(), ff_ape_write_tag(), ff_id3v2_write_metadata(), lrc_write_header(), smjpeg_write_header(), write_globalinfo(), write_metadata(), and write_table_entries_attrib().