From f46ac494483d9724bf52a834e2a897520cbf0546 Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Mon, 24 Feb 2014 21:38:53 -0800 Subject: [PATCH] Add alpha property to movit.opacity filter. --- src/modules/opengl/filter_movit_opacity.cpp | 4 +++- src/modules/opengl/filter_movit_opacity.yml | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/modules/opengl/filter_movit_opacity.cpp b/src/modules/opengl/filter_movit_opacity.cpp index 300145c2..eac29757 100644 --- a/src/modules/opengl/filter_movit_opacity.cpp +++ b/src/modules/opengl/filter_movit_opacity.cpp @@ -34,10 +34,11 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format mlt_position position = mlt_filter_get_position( filter, frame ); mlt_position length = mlt_filter_get_length2( filter, frame ); double opacity = mlt_properties_anim_get_double( properties, "opacity", position, length ); + double alpha = mlt_properties_anim_get_double( properties, "alpha", position, length ); mlt_properties_set_double( properties, "movit.parms.vec4.factor[0]", opacity ); mlt_properties_set_double( properties, "movit.parms.vec4.factor[1]", opacity ); mlt_properties_set_double( properties, "movit.parms.vec4.factor[2]", opacity ); - mlt_properties_set_double( properties, "movit.parms.vec4.factor[3]", opacity ); + mlt_properties_set_double( properties, "movit.parms.vec4.factor[3]", alpha >= 0 ? alpha : opacity ); GlslManager::get_instance()->unlock_service( frame ); *format = mlt_image_glsl; int error = mlt_frame_get_image( frame, image, format, width, height, writable ); @@ -64,6 +65,7 @@ mlt_filter filter_movit_opacity_init( mlt_profile profile, mlt_service_type type mlt_properties properties = MLT_FILTER_PROPERTIES( filter ); glsl->add_ref( properties ); mlt_properties_set( properties, "opacity", arg? arg : "1" ); + mlt_properties_set_double( properties, "alpha", -1.0 ); filter->process = process; } return filter; diff --git a/src/modules/opengl/filter_movit_opacity.yml b/src/modules/opengl/filter_movit_opacity.yml index cf4d1d65..264ce321 100644 --- a/src/modules/opengl/filter_movit_opacity.yml +++ b/src/modules/opengl/filter_movit_opacity.yml @@ -15,6 +15,7 @@ notes: > the other video. If the video this is applied to already has an alpha channel, then this preserves that by multiplying the opacity level with the alpha channel. This filter is especially handy when used in conjunction with movit.overlay. + You can also use this to fade a clip from and to black. parameters: - identifier: opacity @@ -24,3 +25,16 @@ parameters: maximum: 1 default: 1 mutable: yes + + - identifier: alpha + title: Alpha + description: > + When this is less than zero, the alpha component of the Movit mutliply + effect follows opacity. Otherwise, you can set this to another value to + control the alpha component independently. If you set this to 1, then + the opacity parameter can be used to fade to and from black. + type: float + minimum: -1 + maximum: 1 + default: -1 + mutable: yes -- 2.39.2