[FFmpeg-devel] ? Inserting an image in the middle of a video stream

Devin Heitmueller dheitmueller at kernellabs.com
Thu Apr 26 01:24:55 EEST 2018

Hi John,

On Wed, Apr 25, 2018 at 5:11 PM, John P Poet <jppoet at gmail.com> wrote:
> I am working on a project where I need to insert a repeating image (10
> seconds) in the middle of a video stream while also transcoding from one
> video codec to another.  The images are going to be either png or jpg
> images.  I have a frame number within the video stream which tells me where
> to insert the sequence of image frames.

This feels like a case where you might be better off with a video
filter that takes two inputs rather than modifying ffmpeg.c.  The
filter would normally pass through the AVFrames from the first input,
except when you hit the appropriate timestamp, at which point it would
switch to the other input for some period.

Look at the overlay filter as an example.

Alternatively, the filter could take the image to insert as a filter
argument, use libavformat/avcodec to decode it once, and then your
pipeline would be relatively standard.  I believe there are some
examples that do that (look at the filters page and look for entries
that take a jpg/png as a filter argument).


Devin J. Heitmueller - Kernel Labs

More information about the ffmpeg-devel mailing list