static AVFilterLink *graph_run_once_find_filter(AVFilterGraph *graph)
{
    unsigned i, j;
    AVFilterContext *f;

    /* TODO: replace scanning the graph with a priority list */
    for (i = 0; i < graph->nb_filters; i++) {
        f = graph->filters[i];
        for (j = 0; j < f->nb_outputs; j++)
            if (f->outputs[j]->frame_wanted_in)
                return f->outputs[j];
    }
    for (i = 0; i < graph->nb_filters; i++) {
        f = graph->filters[i];
        for (j = 0; j < f->nb_outputs; j++)
            if (f->outputs[j]->frame_wanted_out)
                return f->outputs[j];
    }
    return NULL;
}