[FFmpeg-user] Some help/ideas

JULIAN GARDNER joolzg at btinternet.com
Fri Mar 14 11:20:10 CET 2014


I am working on some new infrasturcture which will allow the playing/overlaying of images on to the main video at predtermined times, i can already add/remove images, which was pretty simple, but what i want now is to be able to take an animated gif/png and play this into my system frame by frame so it looks correct when encoded to its final format.

My code for the single frame image looks like this

static int load_image(uint8_t **image_data, int *w, int *h, int
 *stride,
                     const char *filename, void *log_ctx)
{
    int ret;
    enum AVPixelFormat pix_fmt;
    uint8_t *src_data[4], *dst_data[4];
    int src_linesize[4], dst_linesize[4];

    /* load image from file */
    if ((ret = ff_load_image(src_data, src_linesize, w, h, &pix_fmt, filename, log_ctx)) < 0)
        return ret;

    if ((ret = ff_scale_image(dst_data, dst_linesize, *w, *h, PIXEL_FORMAT,
                              src_data, src_linesize, *w, *h,
 pix_fmt,
                              log_ctx)) < 0)
        goto end;

    *stride = dst_linesize[0];

    /* copy image_data to a newly allocated array */
    *image_data = av_malloc(*stride * *h);
    if (!*image_data)
        ret = AVERROR(ENOMEM);
    av_image_copy_plane(*image_data, *stride, dst_data[0], dst_linesize[0], *w*4, *h);
end:
    av_free(src_data[0]);
    av_free(dst_data[0]);

    return ret;
}

Now this returns a single frame of data containing the image. What i need is a way to load a multi frame gif/png and be able to play each frame individually
 into the system, and my system gets called every frame to add the image onto the main video plane. So if I can load an animated, then have a call and get the next image then that would be perfect.

Any pointers as to how i can do this?

I dont want to add this onto the command line as a '-i' as this is going to dynamic.

joolz


More information about the ffmpeg-user mailing list