# HG changeset patch # User ivo # Date 1152959722 0 # Node ID 30084f2567173219dd8034a6e3eef5b3c8877df6 # Parent 436b3beaa6a3e8198eed64ef10995948299d5b99 print frame type and keep track of last encountered keyframe diff -r 436b3beaa6a3 -r 30084f256717 DOCS/man/en/mplayer.1 --- a/DOCS/man/en/mplayer.1 Sat Jul 15 09:19:12 2006 +0000 +++ b/DOCS/man/en/mplayer.1 Sat Jul 15 10:35:22 2006 +0000 @@ -6263,6 +6263,9 @@ .B blackframe[=amount:threshold] Detect frames that are (almost) completely black. Can be useful to detect chapter transitions or commercials. +Output lines consist of the frame number of the detected frame, the +percentage of blackness, the frame type and the frame number of the last +encountered keyframe. .RSs .IPs percentage of the pixels that have to be below the threshold (default: 98) diff -r 436b3beaa6a3 -r 30084f256717 libmpcodecs/vf_blackframe.c --- a/libmpcodecs/vf_blackframe.c Sat Jul 15 09:19:12 2006 +0000 +++ b/libmpcodecs/vf_blackframe.c Sat Jul 15 10:35:22 2006 +0000 @@ -37,7 +37,7 @@ #include "vf.h" struct vf_priv_s { - unsigned int bamount, bthresh, frame; + unsigned int bamount, bthresh, frame, lastkeyframe; }; static int config(struct vf_instance_s* vf, int width, int height, int d_width, @@ -72,9 +72,11 @@ int nblack=0, pblack=0; unsigned char *yplane = mpi->planes[0]; unsigned int ystride = mpi->stride[0]; + int pict_type = mpi->pict_type; int w = mpi->w, h = mpi->h; int bthresh = vf->priv->bthresh; int bamount = vf->priv->bamount; + static const char *picttypes[4] = { "unknown", "I", "P", "B" }; for (y=1; y<=h; y++) { for (x=0; x 3 || pict_type < 0) pict_type = 0; + if (pict_type == 1) vf->priv->lastkeyframe = vf->priv->frame; + if (pblack >= bamount) - mp_msg(MSGT_VFILTER, MSGL_INFO,"\nBlack frame: frame %u (%2d%%)\n", - vf->priv->frame, pblack); + mp_msg(MSGT_VFILTER, MSGL_INFO,"vf_blackframe: %u, %i%%, %s (I:%u)\n", + vf->priv->frame, pblack, picttypes[pict_type], + vf->priv->lastkeyframe); vf->priv->frame++; @@ -125,6 +131,7 @@ vf->priv->bamount = 98; vf->priv->bthresh = 0x20; vf->priv->frame = 0; + vf->priv->lastkeyframe = 0; if (args) sscanf(args, "%u:%u", &vf->priv->bamount, &vf->priv->bthresh);