78 #define OFFSET(x) offsetof(MovieContext, x)
79 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_VIDEO_PARAM
101 int i, ret, already = 0, stream_id = -1;
102 char type_char[2],
dummy;
106 ret = sscanf(spec,
"d%1[av]%d%c", type_char, &stream_id, &
dummy);
107 if (ret >= 1 && ret <= 2) {
121 "Invalid stream specifier \"%s\"\n", spec);
132 "Ambiguous stream specifier \"%s\", using #%d\n", spec,
i);
139 already ?
"matched only already used streams" :
140 "did not match any stream");
146 "currently unsupported by libavfilter\n", spec,
190 "Channel layout is not set in stream %d, and could not "
191 "be guessed from the number of channels (%d)\n",
198 "Channel layout is not set in output stream %d, "
199 "guessed channel layout is '%s'\n",
211 char default_streams[16], *stream_specs, *spec, *cursor;
223 snprintf(default_streams,
sizeof(default_streams),
"d%c%d",
224 !strcmp(
ctx->filter->name,
"amovie") ?
'a' :
'v',
226 stream_specs = default_streams;
228 for (cursor = stream_specs; *cursor; cursor++)
234 "Loop with several streams is currently unsupported\n");
244 "Failed to avformat_open_input '%s'\n", movie->
file_name);
257 "%s: seek value overflow with start_time:%"PRId64
" seek_point:%"PRId64
"\n",
278 spec =
av_strtok(stream_specs,
"+", &cursor);
286 movie->
st[
i].
st = st;
336 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
350 int list[] = { 0, -1 };
354 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
359 switch (
c->codec_type) {
369 list[0] =
c->sample_rate;
372 list64[0] =
c->channel_layout;
393 switch (
c->codec_type) {
395 outlink->
w =
c->width;
396 outlink->
h =
c->height;
413 "video pts:%s time:%s size:%dx%d aspect:%d/%d",
421 "audio pts:%s time:%s samples:%d",
447 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
463 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
562 for (
int i = 0;
i <
ctx->nb_outputs;
i++) {
570 else if (
i == out_id)
579 }
else if (got_eof) {
595 char *res,
int res_len,
int flags)
600 if (!strcmp(cmd,
"seek")) {
605 if (sscanf(args,
"%i|%"SCNi64
"|%i %1s", &idx, &ts, &
flags, tail) != 3)
612 for (
i = 0;
i <
ctx->nb_outputs;
i++) {
616 }
else if (!strcmp(cmd,
"get_duration")) {
620 if (!res || res_len <= 0)
623 if (args && sscanf(args,
"%1s", tail) == 1)
627 if (print_len < 0 || print_len >= res_len)
636 #if CONFIG_MOVIE_FILTER
644 .priv_class = &movie_class,
657 #if CONFIG_AMOVIE_FILTER
659 #define amovie_options movie_options
672 .priv_class = &amovie_class,
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
Macro definitions for various function/variable attributes.
simple assert() macros that are a bit more flexible than ISO C assert().
Libavcodec external API header.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
static av_cold int init(AVCodecContext *avctx)
char * av_asprintf(const char *fmt,...)
#define flags(name, subs,...)
static av_cold int uninit(AVCodecContext *avctx)
static int got_eagain(void)
static AVInputFormat * iformat
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder.
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_DEFAULT
discard useless packets like 0 size packets in avi
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
ff_const59 AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, AVCodec **decoder_ret, int flags)
Find the "best" stream in the file.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
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 AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_EOF
End of file.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_ROUND_UP
Round toward +infinity.
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.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_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.
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_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static int format_name(const char *buf, char **s, int index, const char *varname)
static int ff_insert_outpad(AVFilterContext *f, unsigned index, AVFilterPad *p)
Insert a new output pad for the filter.
#define AVFILTER_DEFINE_CLASS(fname)
#define FF_OUTLINK_IDX(link)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
static av_cold int movie_common_init(AVFilterContext *ctx)
static int movie_request_frame(AVFilterLink *outlink)
static int open_stream(AVFilterContext *ctx, MovieStream *st)
static av_cold void movie_uninit(AVFilterContext *ctx)
static char * describe_frame_to_str(char *dst, size_t dst_size, AVFrame *frame, enum AVMediaType frame_type, AVFilterLink *link)
static AVStream * find_stream(void *log, AVFormatContext *avf, const char *spec)
static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
Try to push a frame to the requested output.
static int movie_config_output_props(AVFilterLink *outlink)
static int rewind_file(AVFilterContext *ctx)
static const AVOption movie_options[]
static int movie_decode_packet(AVFilterContext *ctx)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static int guess_channel_layout(MovieStream *st, int st_index, void *log_ctx)
static int movie_query_formats(AVFilterContext *ctx)
Describe the class of an AVClass context structure.
main external API structure.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
This struct describes the properties of an encoded stream.
uint64_t channel_layout
Audio only.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
A link between two filters.
AVFilterFormatsConfig incfg
Lists of supported formats / etc.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
int format
agreed upon media format
A filter pad used for either input or output.
int(* request_frame)(AVFilterLink *link)
Frame request callback.
int(* config_props)(AVFilterLink *link)
Link configuration callback.
enum AVMediaType type
AVFilterPad type.
const char * name
Pad name.
const char * name
Filter name.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds.
AVStream ** streams
A list of all streams in the file.
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int64_t best_effort_timestamp
frame timestamp estimated using various heuristics, in stream time base
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
This structure stores compressed data.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
int index
stream index in AVFormatContext
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.
int64_t seek_point
seekpoint in microseconds
int stream_index
for compatibility
AVFormatContext * format_ctx
int max_stream_index
max stream # actually used for output
char * stream_specs
user-provided list of streams, separated by +
int * out_index
stream number -> output number map, or -1
MovieStream * st
array of all streams, one per output
int64_t discontinuity_threshold
int64_t discontinuity_threshold
AVCodecContext * codec_ctx
timestamp utils, mostly useful for debugging/logging purposes
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static av_always_inline int diff(const uint32_t a, const uint32_t b)