On Friday 19 October 2012 16:49:59 Dan Dennedy wrote:
> On Fri, Oct 19, 2012 at 2:46 PM, j-b-m <[email protected]> wrote:
> > Hi,
> > 
> > Following a feature request in Kdenlive (1), I tried to make a few changes
> > to
> > the motion_est filter to allow the detection of scene changes in a clip.
> > 
> > I made 2 changes to the filter:
> > 
> > 1 - add a geometry property "bounding" allowing to process filter on a
> > part of the image only to speed up processing
> 
> ok
> 
> > 2 - Store the scene changes frame positions in a "_scene_cut" property
> > that can later be retrieved by the application
> 
> Why hide the property with the leading underscore? If it is not
> hidden, the someone using melt can use this to serialize the result to
> XML for processing the results. Also, the name should perhaps be a bit
> more consistent with the existing "shot_change"
> 
> Also, for the value, it looks like you are you are making a list of
> frame numbers using a colon delimiter. Hmm.. there might be a case to
> get these as time values (i.e. clock or timecode) in the future. Also,
> there might be a case for making the list format more consistent with
> geometry keyframing where semi-colon is the delimiter. You could then
> use mlt_geometry to construct this value instead of this ad hoc code.
> An app could use mlt_geometry to parse it as well. Then, when
> mlt_geometry is refactored into mlt_properties and a new mlt_rect
> type, it will gain support for time values.

Ok, here is an updated version, trying to use mlt_geometry.

regards
jb

__________________________________________________________________________


diff --git a/src/modules/motion_est/filter_motion_est.c 
b/src/modules/motion_est/filter_motion_est.c
index d2dff28..5ab196e 100644
--- a/src/modules/motion_est/filter_motion_est.c
+++ b/src/modules/motion_est/filter_motion_est.c
@@ -890,6 +890,22 @@ static int filter_get_image( mlt_frame frame, uint8_t 
**image, mlt_image_format
 
        /* Check to see if somebody else has given us bounds */
        struct mlt_geometry_item_s *bounds = mlt_properties_get_data( 
MLT_FRAME_PROPERTIES( frame ), "bounds", NULL );
+       
+       if (bounds == NULL )
+       {
+               char *property = mlt_properties_get( MLT_FILTER_PROPERTIES( 
filter ), 
"bounding" );
+               if ( property != NULL )
+               {
+                       mlt_geometry geometry = mlt_geometry_init( );
+                       mlt_profile profile = mlt_service_profile( 
MLT_FILTER_SERVICE( filter ) 
);
+                       mlt_geometry_parse( geometry, property, 0, 
profile->width, profile-
>height );
+                       struct mlt_geometry_item_s item;
+                       if ( geometry != NULL ) {
+                               mlt_geometry_fetch( geometry, &item, 0 );
+                               bounds = &item;
+                       }
+               }
+       }
 
        if( bounds != NULL ) {
                // translate pixel units (from bounds) to macroblock units
@@ -935,8 +951,29 @@ static int filter_get_image( mlt_frame frame, uint8_t 
**image, mlt_image_format
                if( c->comparison_average > 10 * c->mb_w * c->mb_h &&
                    c->comparison_average > c->previous_msad * 2 )
                {
-                       fprintf(stderr, " - SAD: %d   <<Shot change>>\n", c-
>comparison_average);
-                       mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), 
"shot_change", 
1);
+                       //fprintf(stderr, " - SAD: %d <<Shot change>>\n", 
c->comparison_average 
);
+                       mlt_properties properties = mlt_filter_properties( 
filter );
+                       mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), 
"shot_change", 1 
);
+                       mlt_geometry key_frames = mlt_geometry_init( );
+                       char *property = mlt_properties_get( properties, 
"shot_change_list" );
+                       if ( property ) {
+                               // Parse the geometry if we have one
+                               double length = mlt_filter_get_length2( filter, 
frame );
+                               mlt_geometry_parse( key_frames, property, (int) 
length, -1, -1 );
+                               struct mlt_geometry_item_s item;
+                               item.key = 1;
+                               item.frame = (int) c->current_frame_position;
+                               item.x = c->comparison_average;
+                               item.f[0] = 1;
+                               item.f[1] = 0;
+                               item.f[2] = 0;
+                               item.f[3] = 0;
+                               item.f[4] = 0;
+                               mlt_geometry_insert( key_frames, &item );
+                               mlt_properties_set( properties, 
"shot_change_list", 
mlt_geometry_serialise( key_frames ) );
+                               mlt_geometry_close( key_frames );
+                               
+                       }
                //      c->former_vectors_valid = 0; // Invalidate the previous 
frame's 
predictors
                        c->shot_change = 1;
                }
@@ -1055,7 +1092,6 @@ static int filter_get_image( mlt_frame frame, uint8_t 
**image, mlt_image_format
 
 static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 {
-
        // Keeps tabs on the filter object
        mlt_frame_push_service( frame, this);
 



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Mlt-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to