73 *filename = (
char *)p + 1;
90 *filename = (
char *)p + 1;
108 char *bsf_name, *
buf, *dup, *saveptr;
114 while (bsf_name =
av_strtok(buf,
",", &saveptr)) {
119 "Cannot initialize bitstream filter with name '%s', "
120 "unknown filter or internal error happened\n",
149 char *subselect =
NULL, *next_subselect =
NULL, *first_subselect =
NULL, *tmp_select =
NULL;
154 #define STEAL_OPTION(option, field) do { \
155 if ((entry = av_dict_get(options, option, NULL, 0))) { \
156 field = entry->value; \
157 entry->value = NULL; \
158 av_dict_set(&options, option, NULL, 0); \
189 first_subselect = tmp_select;
190 next_subselect =
NULL;
192 first_subselect =
NULL;
197 "Invalid stream specifier '%s' for output '%s'\n",
247 tee_slave->
avf = avf2;
249 if (!tee_slave->
bsfs) {
256 const char *spec = entry->
key + strlen(
"bsfs");
260 "Specifier separator in '%s' is '%c', but only characters '%s' "
271 "Invalid stream specifier '%s' in bsfs option '%s' for slave "
272 "output '%s'\n", spec, entry->
key, filename);
278 "output '%s'\n", spec, entry->
value, i, filename);
279 if (tee_slave->
bsfs[i]) {
281 "Duplicate bsfs specification associated to stream %d of slave "
282 "output '%s', filters will be ignored\n", i, filename);
288 "Error parsing bitstream filter sequence '%s' associated to "
289 "stream %d of slave output '%s'\n", entry->
value, i, filename);
326 bsf_next = bsf->
next;
343 av_log(log_ctx, log_level,
"filename:'%s' format:%s\n",
349 av_log(log_ctx, log_level,
" stream:%d codec:%s type:%s",
353 av_log(log_ctx, log_level,
" bsfs:");
355 av_log(log_ctx, log_level,
"%s%s",
360 av_log(log_ctx, log_level,
"\n");
367 unsigned nb_slaves = 0, i;
368 const char *filename = avf->
filename;
387 for (i = 0; i < nb_slaves; i++) {
402 "to any slave.\n", i);
407 for (i = 0; i < nb_slaves; i++)
417 int ret_all = 0, ret;
437 int ret_all = 0, ret;
478 .priv_class = &tee_muxer_class,
const char const char void * val
static int tee_write_packet(AVFormatContext *avf, AVPacket *pkt)
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
AVBitStreamFilterContext ** bsfs
bitstream filters per stream
static const char *const slave_opt_delim
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
static int tee_write_trailer(AVFormatContext *avf)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
#define AVIO_FLAG_WRITE
write-only
static const char *const slave_bsfs_spec_sep
static void log_slave(TeeSlave *slave, void *log_ctx, int log_level)
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
Copy the settings of the source AVCodecContext into the destination AVCodecContext.
static const char *const slave_delim
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function...
static const char *const slave_opt_close
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVOutputFormat ff_tee_muxer
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int id
Format-specific stream ID.
static void close_slaves(AVFormatContext *avf)
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.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the 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_LOG_VERBOSE
Detailed information.
const OptionDef options[]
struct AVBitStreamFilterContext * next
static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
static int parse_slave_options(void *log, char *slave, AVDictionary **options, char **filename)
static const char *const slave_select_sep
struct AVOutputFormat * oformat
The output container format.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
attribute_deprecated int av_dup_packet(AVPacket *pkt)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_bitstream_filter_close(AVBitStreamFilterContext *bsf)
Release bitstream filter context.
int * stream_map
map from input to output streams indexes, disabled output streams are set to -1
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
AVRational avg_frame_rate
Average framerate.
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...
AVCodecContext * codec
Codec context associated with this stream.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
char filename[1024]
input or output filename
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.
static const AVClass tee_muxer_class
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
AVBitStreamFilterContext * av_bitstream_filter_init(const char *name)
Create and initialize a bitstream filter context given a bitstream filter name.
static int write_trailer(AVFormatContext *s1)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
TeeSlave slaves[MAX_SLAVES]
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
enum AVMediaType codec_type
char * av_strdup(const char *s)
Duplicate the string s.
AVIOContext * pb
I/O context.
static const char *const slave_opt_open
static const char * format
int av_copy_packet(AVPacket *dst, const AVPacket *src)
Copy packet, including contents.
int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt, AVBitStreamFilterContext *bsfc)
Apply a list of bitstream filters to a packet.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
struct AVBitStreamFilter * filter
Describe the class of an AVClass context structure.
rational number numerator/denominator
static int parse_bsfs(void *log_ctx, const char *bsfs_spec, AVBitStreamFilterContext **bsfs)
Parse list of bitstream filters and add them to the list of filters pointed to by bsfs...
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
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.
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()...
int64_t duration
Decoding: duration of the stream, in stream time base.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
int disposition
AV_DISPOSITION_* bit field.
int64_t nb_frames
number of frames in this stream if known or 0
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
int av_opt_get_key_value(const char **ropts, const char *key_val_sep, const char *pairs_sep, unsigned flags, char **rkey, char **rval)
Extract a key-value pair from the beginning of a string.
void * priv_data
Format private data.
static void write_header(FFV1Context *f)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
AVRational r_frame_rate
Real base framerate of the stream.
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
This structure stores compressed data.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
void(* io_close)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int tee_write_header(AVFormatContext *avf)
#define STEAL_OPTION(option, field)