Using FFmpeg filter without video conversion

Does anyone have an idea of how I can put an image mask over the video without changing the audio & video codec?

I'm making different media files for testing purposes and I want control over my audio and video codecs used in a A/V container, now I need to put an image mask over a A/V file, without changing the audio and video codec.

When using ffmpeg -i video.avi -i image.png -filter_complex 'overlay' avi.mkv I can add -acodec copy but not -vcodec copy, this gives the error:

Streamcopy requested for output streaam 0:0, which is fed from a complex filtergraph. Filtering and streamcopy cannot be used together.

And when just using the above command FFmpeg encodes my streams to another format (MPEG-4 & MP3)


Solution 1:

You answered your own question: filters are incompatible with copy. You're using a video filter there, so you can't use -vcodec copy or -c:v copy; if you were using an audio filter, you would be unable to to use -acodec copy or -c:a copy.

copy, as its name suggests, copies the stream specified exactly, with no changes. Filters alter the stream(s) they target. By definition, copy and filters are incompatible.

If you simply want to choose a specific video codec, then that's simple enough: use -c:v [codecname]; you can see a list of all the codecs your ffmpeg supports with

ffmpeg -codecs

Solution 2:

Since this is for testing simply set a codec with near original quality or even a post-processing format like dnxhd.

# Convert with near original quality compression
ffmpeg -i video.avi -i image.png -filter_complex 'overlay' -vcodec libx265 -crf 10 output.avi

We use libx265 since it yields very high quality video and highly available. A low CRF yields best results with 10 being near original video.