23 #include "libavutil/avutil.h"
24 #include "libavutil/avstring.h"
25 #include "libavutil/opt.h"
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;
318 av_log(log_ctx, log_level,
"filename:'%s' format:%s\n",
324 av_log(log_ctx, log_level,
" stream:%d codec:%s type:%s",
328 av_log(log_ctx, log_level,
" bsfs:");
330 av_log(log_ctx, log_level,
"%s%s",
335 av_log(log_ctx, log_level,
"\n");
342 unsigned nb_slaves = 0, i;
343 const char *filename = avf->
filename;
362 for (i = 0; i < nb_slaves; i++) {
377 "to any slave.\n", i);
382 for (i = 0; i < nb_slaves; i++)
415 bsf_ctx = bsf_ctx->
next;
420 "Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n",
432 int ret_all = 0,
ret;
456 int ret_all = 0,
ret;
496 .priv_class = &tee_muxer_class,
const char const char void * val
static int tee_write_packet(AVFormatContext *avf, AVPacket *pkt)
void * av_calloc(size_t nmemb, size_t size) av_malloc_attrib
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
#define AVERROR_PATCHWELCOME
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
char * av_strdup(const char *s) av_malloc_attrib
Duplicate the string s.
static int filter_packet(void *log_ctx, AVPacket *pkt, AVFormatContext *fmt_ctx, AVBitStreamFilterContext *bsf_ctx)
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
AVCodecContext * codec
Codec context associated with this stream.
static int tee_write_trailer(AVFormatContext *avf)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int av_copy_packet(AVPacket *dst, AVPacket *src)
Copy packet, including contents.
static const char *const slave_bsfs_spec_sep
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static void log_slave(TeeSlave *slave, void *log_ctx, int log_level)
int av_dup_packet(AVPacket *pkt)
struct AVBitStreamFilterContext * next
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
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() and children.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
static const char *const slave_opt_close
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...
AVOutputFormat ff_tee_muxer
const char * av_default_item_name(void *ctx)
Return the context name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
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.
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.
#define AV_LOG_VERBOSE
Detailed information.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
const OptionDef options[]
static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
static int parse_slave_options(void *log, char *slave, AVDictionary **options, char **filename)
#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) av_const
Rescale a 64-bit integer by 2 rational numbers.
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
#define av_err2str(errnum)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void * priv_data
Format private data.
char filename[1024]
input or output filename
#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 **m)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
AVRational avg_frame_rate
Average framerate.
int flags
A combination of AV_PKT_FLAG values.
struct AVBitStreamFilter * filter
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.
unsigned int nb_streams
A list of all streams in the 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() and chilren.
static int write_trailer(AVFormatContext *s1)
TeeSlave slaves[MAX_SLAVES]
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
static const char *const slave_opt_open
main external API structure.
AVIOContext * pb
I/O context.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_OPTION_NOT_FOUND
Describe the class of an AVClass context structure.
static AVFormatContext * fmt_ctx
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.
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...
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()...
int disposition
AV_DISPOSITION_* bit field.
int64_t nb_frames
number of frames in this stream if known or 0
struct AVOutputFormat * oformat
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.
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
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.
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)
AVBitStreamFilterContext * av_bitstream_filter_init(const char *name)
Create and initialize a bitstream filter context given a bitstream filter name.