49 #define OFFSET(x) offsetof(BlackDetectContext, x)
50 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
54 {
"black_min_duration",
"set minimum detected black duration in seconds",
OFFSET(black_min_duration_time),
AV_OPT_TYPE_DOUBLE, {.dbl=2}, 0, DBL_MAX,
FLAGS },
55 {
"picture_black_ratio_th",
"set the picture black ratio threshold",
OFFSET(picture_black_ratio_th),
AV_OPT_TYPE_DOUBLE, {.dbl=.98}, 0, 1,
FLAGS },
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",
144 double picture_black_ratio = 0;
148 for (i = 0; i < inlink->
h; i++) {
149 for (x = 0; x < inlink->
w; x++)
154 picture_black_ratio = (double)blackdetect->
nb_black_pixels / (inlink->
w * inlink->
h);
157 "frame:%"PRId64
" picture_black_ratio:%f pts:%s t:%s type:%c\n",
204 .
name =
"blackdetect",
208 .
inputs = blackdetect_inputs,
209 .
outputs = blackdetect_outputs,
210 .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 inputs[]
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.
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.
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[]
AVPixelFormat
Pixel format.
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)