%out and %fade variable in custom frei0r effect

Hello!

I’m trying to write a frei0r effect for Kdenlive but I’m having some trouble with the %out and %fade variable. I took the XML parameters from the fade_to_black effect and put those in my own XML file. I tried reading them and that works but it looks like they aren’t updating properly when the clip changes length.

Here I’m applying my effect to a simple color clip:

(Apparently I’m not allowed to embed multiple files? so I’m using a different host for my images from here)

I go to the part where the effect is supposed to be active and that works (currently, the effect sets all pixels to #000000):

But when I extend the clip and go to the extended part, my effect is not being applied:

Here is the source code of my effect:

#include <float.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "frei0r.h"

typedef struct catastrophe_instance {
	unsigned int width;
	unsigned int height;

	int in;
	int out;
} catastrophe_instance_t;

int f0r_init()
{
	return 1;
}

void f0r_deinit()
{}

void f0r_get_plugin_info(f0r_plugin_info_t *catastrophe_info)
{
	catastrophe_info->name = "bk_catastrophe";
	catastrophe_info->author = "BIG KRIMPIN";
	catastrophe_info->plugin_type = F0R_PLUGIN_TYPE_FILTER;
	catastrophe_info->color_model = F0R_COLOR_MODEL_RGBA8888;
	catastrophe_info->frei0r_version = FREI0R_MAJOR_VERSION;
	catastrophe_info->major_version = 0;
	catastrophe_info->minor_version = 1;
	catastrophe_info->num_params = 2;
	catastrophe_info->explanation = "Simulates the DOOM melting title screen";
}

f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
{
	catastrophe_instance_t *inst = (catastrophe_instance_t*)calloc(1, sizeof(*inst));

	inst->width = width;
	inst->height = height;
	inst->in = 0;
	inst->out = 0;

	return (f0r_instance_t)inst;
}

void f0r_destruct(f0r_instance_t instance)
{
	free(instance);
}

void f0r_get_param_info(f0r_param_info_t *info, int param_index)
{
	switch(param_index)
	{
		case 0:
			info->name = "in";
			info->type = F0R_PARAM_DOUBLE;
			info->explanation = "";
			break;
		case 1:
			info->name = "out";
			info->type = F0R_PARAM_DOUBLE;
			info->explanation = "";
			break;
	}
}

void f0r_set_param_value(f0r_instance_t instance, f0r_param_t param,
		int param_index)
{
	catastrophe_instance_t *inst = (catastrophe_instance_t*)instance;
	switch(param_index)
	{
		case 0:
			printf("in set\n");
			inst->in = *((double*)param);
			break;
		case 1:
			printf("out set\n");
			inst->out = *((double*)param);
			break;
	}
}

void f0r_get_param_value(f0r_instance_t instance, f0r_param_t param,
		int param_index)
{
	catastrophe_instance_t *inst = (catastrophe_instance_t*)instance;
	switch(param_index)
	{
		case 0:
			*((double*)param) = inst->in;
			break;
		case 1:
			*((double*)param) = inst->out;
			break;
	}
}

// Give every strip a random number as the speed of the downwards motion.
// Move each strip downwards with it's own speed
// After 10-20% of the given time, move every strip with the same speed

void f0r_update(f0r_instance_t instance, double time, const uint32_t *inframe,
		uint32_t *outframe)
{
	catastrophe_instance_t *inst = (catastrophe_instance_t*)instance;
	int w = inst->width;
	int h = inst->height;
	
	memset(outframe, 0x00, sizeof(uint32_t) * w * h);
	printf("%f\n", time);
	printf("in: %d\n", inst->in);
	printf("out: %d\n", inst->out);
}

And corresponding XML file:

<?xml version="1.0"?>
<!DOCTYPE kpartgui>
<effect tag="frei0r.bk_catastrophe" id="frei0r.bk_catastrophe" type="video" unique="1">
	<name>bk_catastrophe</name>
	<description>Simulates the DOOM melting title screen</description>
	<author>BIG KRIMPIN</author>

	<parameter type="position" name="in" max="0" min="0" default="-%fade">
		<name>Duration</name>
	</parameter>
	<parameter type="fixed" name="out" max="90000" min="0" default="%out">
		<name/>
	</parameter>
</effect>

Am I doing something wrong? Is this a known limitation of the frei0r integration? Or is this a bug?

Duration is still at 3:00, so wouldn’t that mean that after 3s the effect stops? I think you want the duration to be adjusted accordingly if the clip length changes, right?

BTW, it’s great you are taking a stab at writing effects.

Not exactly, it works the same way as the fade out effect in that it’s 3s from the end of the clip (in fact, I copied it straight from the fade_to_black XML file).

I’ve already written some other effects and it’s been great fun being able to add stuff to Kdenlive that I felt it lacked.

1 Like

Why are they not available then? Do you have to bribe someone at MLT to make them available? wavr seems like a good candidate because wave has been deprecated …

I mean, they are, just run this:

git clone --recurse-submodules https://github.com/bigkrimpin/b1ggiekr1mps
cd b1ggiekr1mps
make
sudo make install

I’m not going to make a pull request to push them upstream, I’d like to keep governance over my projects.

Ok, got it. Thanks!

But what if not everyone can do this? Like if you are on Windows?