Go to the documentation of this file.
37 #define DEFAULT_SLAVE_FAILURE_POLICY ON_SLAVE_FAILURE_ABORT
66 #define OFFSET(x) offsetof(TeeContext, x)
68 {
"use_fifo",
"Use fifo pseudo-muxer to separate actual muxers from encoder",
70 {
"fifo_options",
"fifo pseudo-muxer options",
OFFSET(fifo_options),
103 if (
av_match_name(use_fifo,
"true,y,yes,enable,enabled,on,1")) {
105 }
else if (
av_match_name(use_fifo,
"false,n,no,disable,disabled,off,0")) {
125 avf = tee_slave->
avf;
132 if (tee_slave->
bsfs) {
163 char *use_fifo =
NULL, *fifo_options_str =
NULL;
168 char *subselect =
NULL, *next_subselect =
NULL, *first_subselect =
NULL, *tmp_select =
NULL;
173 #define CONSUME_OPTION(option, field, action) do { \
174 if ((entry = av_dict_get(options, option, NULL, 0))) { \
175 field = entry->value; \
177 av_dict_set(&options, option, NULL, 0); \
180 #define STEAL_OPTION(option, field) \
181 CONSUME_OPTION(option, field, \
182 entry->value = NULL; )
183 #define PROCESS_OPTION(option, field, function, on_error) \
184 CONSUME_OPTION(option, field, if ((ret = function) < 0) { { on_error } goto end; })
191 "valid options are 'abort' and 'ignore'\n"););
201 av_dict_set(&bsf_options, entry->key + 4, entry->value, 0);
208 char *format_options_str =
NULL;
235 tee_slave->
avf = avf2;
261 first_subselect = tmp_select;
262 next_subselect =
NULL;
264 first_subselect =
NULL;
269 "Invalid stream specifier '%s' for output '%s'\n",
312 if (!tee_slave->
bsfs) {
319 const char *spec = entry->key;
323 "Specifier separator in '%s' is '%c', but only characters '%s' "
335 "Invalid stream specifier '%s' in bsfs option '%s' for slave "
336 "output '%s'\n", spec, entry->key, filename);
342 "output '%s'\n", spec, entry->value,
i, filename);
343 if (tee_slave->
bsfs[
i]) {
345 "Duplicate bsfs specification associated to stream %d of slave "
346 "output '%s', filters will be ignored\n",
i, filename);
352 "Error parsing bitstream filter sequence '%s' associated to "
353 "stream %d of slave output '%s'\n", entry->value,
i, filename);
364 if (target_stream < 0)
367 if (!tee_slave->
bsfs[target_stream]) {
372 "Failed to create pass-through bitstream filter: %s\n",
387 "Failed to initialize bitstream filter(s): %s\n",
413 av_log(log_ctx, log_level,
"filename:'%s' format:%s\n",
418 const char *bsf_name;
420 av_log(log_ctx, log_level,
" stream:%d codec:%s type:%s",
426 av_log(log_ctx, log_level,
" bsfs: %s\n", bsf_name);
446 av_log(avf,
AV_LOG_ERROR,
"Slave muxer #%u failed: %s, continuing with %u/%u slaves.\n",
455 unsigned nb_slaves = 0,
i;
456 const char *filename = avf->
url;
457 char **slaves =
NULL;
481 for (
i = 0;
i < nb_slaves;
i++) {
505 "to any slave.\n",
i);
511 for (
i = 0;
i < nb_slaves;
i++)
521 int ret_all = 0,
ret;
527 if (!ret_all &&
ret < 0)
541 int ret_all = 0,
ret;
554 if (!ret_all &&
ret < 0)
579 if (!ret_all &&
ret < 0)
588 }
else if (
ret < 0) {
601 if (!ret_all &&
ret < 0)
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVCodecParameters * par_in
Parameters of the input stream.
#define AV_LOG_WARNING
Something somehow does not look correct.
@ ON_SLAVE_FAILURE_IGNORE
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVBSFContext ** bsfs
bitstream filters per stream
enum AVMediaType codec_type
General type of the encoded data.
int * stream_map
map from input to output streams indexes, disabled output streams are set to -1
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src)
Copy encoding parameters from source to destination stream.
AVStream ** streams
A list of all streams in the file.
int strict_std_compliance
Allow non-standard and experimental extension.
static int parse_slave_fifo_options(const char *fifo_options, TeeSlave *tee_slave)
int ff_tee_parse_slave_options(void *log, char *slave, AVDictionary **options, char **filename)
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
#define AV_LOG_VERBOSE
Detailed information.
static int tee_write_trailer(AVFormatContext *avf)
static int tee_write_packet(AVFormatContext *avf, AVPacket *pkt)
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
The bitstream filter state.
#define STEAL_OPTION(option, field)
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
static int parse_slave_fifo_policy(const char *use_fifo, TeeSlave *tee_slave)
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
static const AVClass tee_muxer_class
int flags
Flags modifying the (de)muxer behaviour.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
static const char *const slave_bsfs_spec_sep
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVRational time_base_in
The timebase used for the timestamps of the input packets.
AVDictionary * fifo_options
static const char *const slave_select_sep
static int tee_process_slave_failure(AVFormatContext *avf, unsigned slave_idx, int err_n)
av_warn_unused_result int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
static int write_trailer(AVFormatContext *s1)
const char * av_default_item_name(void *ptr)
Return the context name.
static int close_slave(TeeSlave *tee_slave)
AVIOContext * pb
I/O context.
const AVClass * priv_class
A class for the private data, used to declare bitstream filter private AVOptions.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
SlaveFailurePolicy on_fail
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the stream st contained in s is matched by the stream specifier spec.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
char * url
input or output URL.
static void close_slaves(AVFormatContext *avf)
AVDictionary * fifo_options
#define DEFAULT_SLAVE_FAILURE_POLICY
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static const AVOption options[]
void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
Convert valid timing fields (timestamps / durations) in a packet from one timebase to another.
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
#define i(width, name, range_min, range_max)
AVRational time_base_out
The timebase used for the timestamps of the output packets.
void * av_calloc(size_t nmemb, size_t size)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int av_bsf_get_null_filter(AVBSFContext **bsf)
Get null/pass-through bitstream filter.
const struct AVOutputFormat * oformat
The output container format.
static int parse_slave_failure_policy_option(const char *opt, TeeSlave *tee_slave)
static void log_slave(TeeSlave *slave, void *log_ctx, int log_level)
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
static int tee_write_header(AVFormatContext *avf)
int av_match_name(const char *name, const char *names)
Match instances of a name in a comma-separated list of names.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
void(* io_close)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
static const char *const slave_delim
#define PROCESS_OPTION(option, field, function, on_error)
const struct AVBitStreamFilter * filter
The bitstream filter this context is an instance of.
char * av_strdup(const char *s)
Duplicate a string.
int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
Parse string describing list of bitstream filters and create single AVBSFContext describing the whole...
AVPacket * pkt
Used to hold temporary packets for the generic demuxing code.
const AVOutputFormat ff_tee_muxer
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_get_string(const AVDictionary *m, char **buffer, const char key_val_sep, const char pairs_sep)
Get dictionary entries as a string.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
int(* io_close2)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
#define flags(name, subs,...)
int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **options)
Utility function to open IO stream of output format.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
const char *(* item_name)(void *ctx)
A pointer to a function which returns the name of a context instance ctx associated with the class.
static void write_header(FFV1Context *f)
void * priv_data
Format private data.