70 *filename = (
char *)p + 1;
87 *filename = (
char *)p + 1;
105 char *bsf_name, *
buf, *dup, *saveptr;
111 while (bsf_name =
av_strtok(buf,
",", &saveptr)) {
116 "Cannot initialize bitstream filter with name '%s', "
117 "unknown filter or internal error happened\n",
141 char *format =
NULL, *select =
NULL;
149 #define STEAL_OPTION(option, field) do { \
150 if ((entry = av_dict_get(options, option, NULL, 0))) { \
151 field = entry->value; \
152 entry->value = NULL; \
153 av_dict_set(&options, option, NULL, 0); \
178 "Invalid stream specifier '%s' for output '%s'\n",
222 tee_slave->
avf = avf2;
224 if (!tee_slave->
bsfs) {
231 const char *spec = entry->
key + strlen(
"bsfs");
235 "Specifier separator in '%s' is '%c', but only characters '%s' "
246 "Invalid stream specifier '%s' in bsfs option '%s' for slave "
247 "output '%s'\n", spec, entry->
key, filename);
253 "output '%s'\n", spec, entry->
value, i, filename);
254 if (tee_slave->
bsfs[i]) {
256 "Duplicate bsfs specification associated to stream %d of slave "
257 "output '%s', filters will be ignored\n", i, filename);
263 "Error parsing bitstream filter sequence '%s' associated to "
264 "stream %d of slave output '%s'\n", entry->
value, i, filename);
300 bsf_next = bsf->
next;
317 av_log(log_ctx, log_level,
"filename:'%s' format:%s\n",
323 av_log(log_ctx, log_level,
" stream:%d codec:%s type:%s",
327 av_log(log_ctx, log_level,
" bsfs:");
329 av_log(log_ctx, log_level,
"%s%s",
334 av_log(log_ctx, log_level,
"\n");
341 unsigned nb_slaves = 0, i;
342 const char *filename = avf->
filename;
361 for (i = 0; i < nb_slaves; i++) {
376 "to any slave.\n", i);
381 for (i = 0; i < nb_slaves; i++)
414 "Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n",
420 bsf_ctx = bsf_ctx->
next;
430 int ret_all = 0,
ret;
453 int ret_all = 0,
ret;
493 .priv_class = &tee_muxer_class,
int avio_open(AVIOContext **s, const char *url, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
const char const char void * val
static int tee_write_packet(AVFormatContext *avf, AVPacket *pkt)
void av_free_packet(AVPacket *pkt)
Free a packet.
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
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 char *const slave_opt_delim
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
static int filter_packet(void *log_ctx, AVPacket *pkt, AVFormatContext *fmt_ctx, AVBitStreamFilterContext *bsf_ctx)
static AVFormatContext * fmt_ctx
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_dup_packet(AVPacket *pkt)
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
attribute_deprecated void(* destruct)(struct AVPacket *)
static av_cold int end(AVCodecContext *avctx)
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.
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
const OptionDef options[]
void av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
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)
struct AVOutputFormat * oformat
The output container format.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
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. ...
#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. ...
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
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...
int flags
A combination of AV_PKT_FLAG values.
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
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.
int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
Filter bitstream.
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
main external API structure.
int av_copy_packet(AVPacket *dst, const AVPacket *src)
Copy packet, including contents.
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.
This structure stores compressed data.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
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)