[libav-api] Overlay filter outputs distorted frame

g kuczera gkuczera at gmail.com
Wed Aug 6 12:39:58 CEST 2014


I don't know if this is a proper way to replay, but I just want to inform
you, that I solved the problem with advice from Luca Barbato.

What was wrong with my code, was the lack of FormatFilter, which I added
later.

Thanks for help!

Here is the code:
http://stackoverflow.com/questions/24933207/overlay-filter-in-libav-ffmpeg-returns-strange-tripled-frame-in-c

{ // FORMAT FILTER
    tFormat = avfilter_get_by_name("format");
    if (!tFormat) {
        // Could not find the tFormat filter.
        return -1;
    }

    tFormatContext = avfilter_graph_alloc_filter(tFilterGraph,
tFormat, "format");
    if (!tFormatContext) {
        // Could not allocate the tFormat instance.
        return -1;
    }

    av_dict_set(&tOptionsDict, "pix_fmts", "bgr24", 0);
    tError = avfilter_init_dict(tFormatContext, &tOptionsDict);
    av_dict_free(&tOptionsDict);
    if (tError < 0) {
        // Could not initialize the tFormat filter.
        return tError;
    }}


And linking the filter graph:

tError = avfilter_link(tBufferContext1, 0, tOverlayContext, 0);if (tError >= 0){
    tError = avfilter_link(tColorContext, 0, tOverlayContext, 1);}if
(tError >= 0){
    tError = avfilter_link(tOverlayContext, 0, tFormatContext, 0);}if
(tError >= 0){
    tError = avfilter_link(tFormatContext, 0, tBufferSinkContext,
0);}if (tError < 0) { // Error connecting filters.
    return tError;}


More information about the libav-api mailing list