[FFmpeg-user] try to change complex filters on runtime
lucie Lemonnier
lucielemonnier at hotmail.fr
Wed Jul 10 15:43:57 CEST 2013
Hello,
I want to change
complex filters on runtime by changing the code of ffmpeg.c to change
between different overlays or to change the value of x in crop
parameters.
Before, i tried to change the overlays and crop with the
use of simple filter.To try this, I call a fuction "filter_change" in
the function transcode_step :
void filter_change(char* newfilter){
ost->avfilter = av_strdup(newfilter);
if (configure_filtergraph(ost->filter->graph)) {
av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n");
exit(1);
}
}
I call for example : filter_change("movie = objets.png [mv1];[in][mv1] overlay=0:0 [out];[out] crop=1920:1080:0:0");
or
filter_change("movie = transp.mov [mv1];[in][mv1] overlay=0:0 [out];[out] crop=1920:1080:0:0");
I
use rtp to output. But when I add a video overlay for example, the
output video (rtp) freeze and the output with overlay reappears after 5
to 10 seconds. It's too long. I need a real-time change or almost.
That's why I test with complex filters.
I create a function reinit_filters_complex that I call in transcode_step :
void reinit_filters_complex(const char *arg){
int i,j;
for (i = 0; i < nb_filtergraphs; i++) {
avfilter_graph_free(&filtergraphs[i]->graph);
for (j = 0; j < filtergraphs[i]->nb_inputs; j++) {
av_freep(&filtergraphs[i]->inputs[j]->name);
av_freep(&filtergraphs[i]->inputs[j]);
}
av_freep(&filtergraphs[i]->inputs);
for (j = 0; j < filtergraphs[i]->nb_outputs; j++) {
av_freep(&filtergraphs[i]->outputs[j]->name);
av_freep(&filtergraphs[i]->outputs[j]);
}
av_freep(&filtergraphs[i]->outputs);
av_freep(&filtergraphs[i]);
}
av_freep(&filtergraphs);
nb_filtergraphs = 0;
GROW_ARRAY(filtergraphs, nb_filtergraphs);
if (!(filtergraphs[nb_filtergraphs - 1] = av_mallocz(sizeof(*filtergraphs[0]))))
return AVERROR(ENOMEM);
filtergraphs[nb_filtergraphs - 1]->index = nb_filtergraphs - 1;
filtergraphs[nb_filtergraphs - 1]->graph_desc = arg;
configure_complex_filters();
}
For
example , I call reinit_filters_complex("[0:0] crop=960:1080:0:0
[tin];[2:0] crop=960:1080:0:0 [tmv]);[tin][tmv]overlay=0:0").
I
passed in parameters of ffmpeg -i videoSource.mp4 -i transp.mov -i
objets.png -filter_complex "[0:0] crop=960:1080:0:0 [tin];[1:0]
crop=960:1080:0:0 [tmv]".
But It crash on this change.
I think it's because I free all in filtergraphs.
But I don't know what is missing for it to work.
Can you help me, please?
Thanks.
More information about the ffmpeg-user
mailing list