56#define INPUT_SAMPLERATE 48000
57#define INPUT_FORMAT AV_SAMPLE_FMT_FLTP
58#define INPUT_CHANNEL_LAYOUT (AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0
60#define VOLUME_VAL 0.90
76 uint8_t options_str[1024];
77 uint8_t ch_layout[64];
84 fprintf(stderr,
"Unable to create filter graph.\n");
92 fprintf(stderr,
"Could not find the abuffer filter.\n");
98 fprintf(stderr,
"Could not allocate the abuffer instance.\n");
113 fprintf(stderr,
"Could not initialize the abuffer filter.\n");
120 fprintf(stderr,
"Could not find the volume filter.\n");
126 fprintf(stderr,
"Could not allocate the volume instance.\n");
136 fprintf(stderr,
"Could not initialize the volume filter.\n");
144 fprintf(stderr,
"Could not find the aformat filter.\n");
150 fprintf(stderr,
"Could not allocate the aformat instance.\n");
156 snprintf(options_str,
sizeof(options_str),
157 "sample_fmts=%s:sample_rates=%d:channel_layouts=stereo",
169 fprintf(stderr,
"Could not find the abuffersink filter.\n");
174 if (!abuffersink_ctx) {
175 fprintf(stderr,
"Could not allocate the abuffersink instance.\n");
182 fprintf(stderr,
"Could not initialize the abuffersink instance.\n");
194 fprintf(stderr,
"Error connecting filters\n");
207 *sink = abuffersink_ctx;
218 int planes = planar ? channels : 1;
223 for (i = 0; i < planes; i++) {
224 uint8_t checksum[16];
229 fprintf(stdout,
"plane %d: 0x", i);
230 for (j = 0; j <
sizeof(checksum); j++)
231 fprintf(stdout,
"%02X", checksum[j]);
232 fprintf(stdout,
"\n");
234 fprintf(stdout,
"\n");
245#define FRAME_SIZE 1024
259 for (i = 0; i < 5; i++) {
269int main(
int argc,
char *argv[])
275 uint8_t errstr[1024];
277 int err, nb_frames, i;
280 fprintf(stderr,
"Usage: %s <duration>\n", argv[0]);
284 duration = atof(argv[1]);
286 if (nb_frames <= 0) {
287 fprintf(stderr,
"Invalid duration: %s\n", argv[1]);
294 fprintf(stderr,
"Error allocating the frame\n");
300 fprintf(stderr,
"Error allocating the MD5 context\n");
307 fprintf(stderr,
"Unable to init filter graph:");
312 for (i = 0; i < nb_frames; i++) {
316 fprintf(stderr,
"Error generating input frame:");
324 fprintf(stderr,
"Error submitting the frame to the filtergraph:");
333 fprintf(stderr,
"Error processing the filtered frame:");
345 }
else if (err < 0) {
347 fprintf(stderr,
"Error filtering the data:");
360 fprintf(stderr,
"%s\n", errstr);
Main libavfilter public API header.
memory buffer sink API for audio and video
Memory buffer source API.
audio channel layout utility functions
int main(int argc, char *argv[])
static int get_input(AVFrame *frame, int frame_num)
static int process_output(struct AVMD5 *md5, AVFrame *frame)
static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src, AVFilterContext **sink)
#define INPUT_CHANNEL_LAYOUT
AVFilterGraph * filter_graph
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame)
Get a frame with filtered data from sink and put it in frame.
av_warn_unused_result int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
int avfilter_init_str(AVFilterContext *ctx, const char *args)
Initialize a filter with the supplied parameters.
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
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.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
void av_dict_free(AVDictionary **m)
Free all the memory allocated for an AVDictionary struct and all keys and values.
struct AVDictionary AVDictionary
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_FILTER_NOT_FOUND
Filter not found.
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
#define AVERROR_EOF
End of file.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
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_ERROR
Something went wrong and cannot losslessly be recovered.
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.
void av_md5_init(struct AVMD5 *ctx)
Initialize MD5 hashing.
void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len)
Hash an array of data.
struct AVMD5 * av_md5_alloc(void)
Allocate an AVMD5 context.
void av_freep(void *ptr)
Free a memory block which has been allocated with a function of av_malloc() or av_realloc() family,...
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
@ AV_SAMPLE_FMT_S16
signed 16 bits
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
int av_opt_set_q(void *obj, const char *name, AVRational val, int search_flags)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Public header for MD5 hash function implementation.
Memory handling functions.
int nb_channels
Number of channels in this layout.
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).
int sample_rate
Sample rate of the audio data.
AVChannelLayout ch_layout
Channel layout of the audio data.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
uint8_t ** extended_data
pointers to the data planes/channels.
Rational number (pair of numerator and denominator).