49 #define OFFSET(x) offsetof(BlackDetectContext, x) 50 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM 64 #define YUVJ_FORMATS \ 65 AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P 103 "black_min_duration:%s pixel_black_th:%f pixel_black_th_i:%d picture_black_ratio_th:%f\n",
117 "black_start:%s black_end:%s black_duration:%s\n",
143 double picture_black_ratio = 0;
147 for (i = 0; i < inlink->
h; i++) {
148 for (x = 0; x < inlink->
w; x++)
153 picture_black_ratio = (double)blackdetect->
nb_black_pixels / (inlink->
w * inlink->
h);
156 "frame:%"PRId64
" picture_black_ratio:%f pts:%s t:%s type:%c\n",
203 .
name =
"blackdetect",
207 .
inputs = blackdetect_inputs,
208 .
outputs = blackdetect_outputs,
209 .priv_class = &blackdetect_class,
This structure describes decoded (raw) audio or video data.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Main libavfilter public API header.
int h
agreed upon image height
AVFilter ff_vf_blackdetect
unsigned int nb_black_pixels
number of black pixels counted so far
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
static const AVFilterPad blackdetect_inputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int config_input(AVFilterLink *inlink)
timestamp utils, mostly useful for debugging/logging purposes
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static int query_formats(AVFilterContext *ctx)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
AVDictionary * metadata
metadata.
int64_t black_min_duration
minimum duration of detected black, expressed in timebase units
double picture_black_ratio_th
A filter pad used for either input or output.
A link between two filters.
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
static const AVFilterPad blackdetect_outputs[]
as above, but U and V bytes are swapped
enum AVPictureType pict_type
Picture type of the frame.
double black_min_duration_time
minimum duration of detected black, in seconds
int64_t last_picref_pts
pts of the last input picture
unsigned int pixel_black_th_i
AVFilterContext * src
source filter
AVFILTER_DEFINE_CLASS(blackdetect)
static const AVFilterPad outputs[]
int format
agreed upon media format
static void check_black_end(AVFilterContext *ctx)
#define AV_LOG_INFO
Standard information.
static enum AVPixelFormat yuvj_formats[]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
int64_t black_end
pts end time of the last black picture
Describe the class of an AVClass context structure.
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
int64_t black_start
pts start time of the first black picture
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
AVFilterContext * dst
dest filter
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static int request_frame(AVFilterLink *outlink)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
static const AVOption blackdetect_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 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
AVPixelFormat
Pixel format.
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)