Go to the documentation of this file.
29 #include "config_components.h"
87 #define OFFSET(x) offsetof(MovieContext, x)
88 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_VIDEO_PARAM
102 {
"dec_threads",
"set the number of threads for decoding",
OFFSET(dec_threads),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
FLAGS },
111 int i,
ret, already = 0, stream_id = -1;
112 char type_char[2],
dummy;
116 ret = sscanf(spec,
"d%1[av]%d%c", type_char, &stream_id, &
dummy);
117 if (
ret >= 1 &&
ret <= 2) {
131 "Invalid stream specifier \"%s\"\n", spec);
142 "Ambiguous stream specifier \"%s\", using #%d\n", spec,
i);
149 already ?
"matched only already used streams" :
150 "did not match any stream");
156 "currently unsupported by libavfilter\n", spec,
168 int w,
h, ow, oh,
copy = 0;
177 if (
w != outlink->
w ||
h != outlink->
h)
256 "Channel layout is not set in stream %d, and could not "
257 "be guessed from the number of channels (%d)\n",
264 "Channel layout is not set in output stream %d, "
265 "guessed channel layout is '%s'\n",
276 char default_streams[16], *stream_specs, *spec, *cursor;
288 snprintf(default_streams,
sizeof(default_streams),
"d%c%d",
289 !strcmp(
ctx->filter->name,
"amovie") ?
'a' :
'v',
291 stream_specs = default_streams;
293 for (cursor = stream_specs; *cursor; cursor++)
299 "Loop with several streams is currently unsupported\n");
309 "Failed to avformat_open_input '%s'\n", movie->
file_name);
322 "%s: seek value overflow with start_time:%"PRId64
" seek_point:%"PRId64
"\n",
346 spec =
av_strtok(stream_specs,
"+", &cursor);
354 movie->
st[
i].
st = st;
405 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
420 int list[] = { 0, -1 };
424 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
429 switch (
c->codec_type) {
439 list[0] =
c->sample_rate;
442 list64[0] =
c->ch_layout;
463 switch (
c->codec_type) {
465 outlink->
w =
c->width;
466 outlink->
h =
c->height;
493 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
566 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
578 for (
int i = 0;
i <
ctx->nb_outputs;
i++)
586 if (pkt_out_id >= 0) {
591 return (
ret <= 0) ?
ret : 0;
596 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
602 nb_eofs += movie->
st[
i].
eof == 1;
611 for (
int i = 0;
i <
ctx->nb_outputs;
i++)
616 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
624 if (nb_eofs < ctx->nb_outputs)
633 char *res,
int res_len,
int flags)
638 if (!strcmp(cmd,
"seek")) {
643 if (sscanf(args,
"%i|%"SCNi64
"|%i %1s", &idx, &ts, &
flags, tail) != 3)
650 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
654 }
else if (!strcmp(cmd,
"get_duration")) {
658 if (!res || res_len <= 0)
661 if (args && sscanf(args,
"%1s", tail) == 1)
665 if (print_len < 0 || print_len >= res_len)
676 #if CONFIG_MOVIE_FILTER
682 .priv_class = &movie_class,
696 #if CONFIG_AMOVIE_FILTER
701 .priv_class = &movie_class,
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
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
enum AVMediaType codec_type
General type of the encoded data.
This struct describes the properties of an encoded stream.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AVERROR_EOF
End of file.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int stream_index
for compatibility
char * av_asprintf(const char *fmt,...)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
AVStream ** streams
A list of all streams in the file.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int capabilities
Codec capabilities.
#define FILTER_QUERY_FUNC(func)
AVDictionary * format_opts
#define AV_LOG_VERBOSE
Detailed information.
static const AVOption movie_options[]
const char * name
Filter name.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int nb_channels
Number of channels in this layout.
A link between two filters.
static int guess_channel_layout(MovieStream *st, int st_index, void *log_ctx)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
const AVFilter ff_avsrc_movie
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
int * out_index
stream number -> output number map, or -1
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
const struct AVCodec * codec
static int decode_packet(AVFilterContext *ctx, int i)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
AVChannelLayout ch_layout
Channel layout of the audio data.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
@ AV_ROUND_UP
Round toward +infinity.
const AVFilter ff_avsrc_amovie
A filter pad used for either input or output.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int(* get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags)
This callback is called at the beginning of each frame to get data buffer(s) for it.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
#define FF_OUTLINK_IDX(link)
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(* init)(AVBSFContext *ctx)
int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder or encoder (when the AV_CODEC_FLAG_RECON_FRAME flag is used...
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS])
Modify width and height values so that they will result in a memory buffer that is acceptable for the...
AVFormatContext * format_ctx
static AVStream * find_stream(void *log, AVFormatContext *avf, const char *spec)
@ AVDISCARD_ALL
discard all
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avcodec_parameters_to_context(AVCodecContext *codec, const struct AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
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.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
int64_t discontinuity_threshold
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
int64_t discontinuity_threshold
AVFILTER_DEFINE_CLASS_EXT(movie, "(a)movie", movie_options)
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 list
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVChannelLayout ch_layout
Audio only.
AVCodecContext * codec_ctx
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
int64_t best_effort_timestamp
frame timestamp estimated using various heuristics, in stream time base
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int(* config_props)(AVFilterLink *link)
Link configuration callback.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
static av_cold int movie_common_init(AVFilterContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
static int movie_query_formats(AVFilterContext *ctx)
static av_cold void movie_uninit(AVFilterContext *ctx)
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.
static void copy(const float *p1, float *p2, const int length)
@ AVDISCARD_DEFAULT
discard useless packets like 0 size packets in avi
An AVChannelLayout holds information about the channel layout of audio data.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int sample_rate
Sample rate of the audio data.
int format
agreed upon media format
#define AV_NUM_DATA_POINTERS
#define AV_NOPTS_VALUE
Undefined timestamp value.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
AVFilterContext * src
source filter
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
AVFilterFormatsConfig incfg
Lists of supported formats / etc.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
AVDictionary * format_opts
static const AVInputFormat * iformat
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
int sample_rate
samples per second
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
int w
agreed upon image width
static int rewind_file(AVFilterContext *ctx)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int max_stream_index
max stream # actually used for output
const char * name
Pad name.
void * av_calloc(size_t nmemb, size_t size)
enum AVMediaType type
AVFilterPad type.
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
void * opaque
Private data of the user, can be used to carry app specific stuff.
static int activate(AVFilterContext *ctx)
static int movie_config_output_props(AVFilterLink *outlink)
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.
main external API structure.
int index
stream index in AVFormatContext
static int format_name(const char *buf, char **s, int index, const char *varname)
int h
agreed upon image height
static int flush_decoder(AVFilterContext *ctx, int i)
AVRational r_frame_rate
Real base framerate of the stream.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
const AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
char * stream_specs
user-provided list of streams, separated by +
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
MovieStream * st
array of all streams, one per output
enum AVMediaType codec_type
AVFrame * ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
default handler for get_audio_buffer() for audio inputs
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int ff_append_outpad_free_name(AVFilterContext *f, AVFilterPad *p)
#define flags(name, subs,...)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int64_t seek_point
seekpoint in microseconds
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds.
static av_cold int uninit(AVCodecContext *avctx)
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads)
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.