

Add watermarks or anything you want to overlay onto the video GraphicsMagick is used in this example:įor f in frames/*.png do gm composite -geometry +0+640 wm-bl.png "$f" "$f" gm composite -geometry +1100+640 wm-br.png "$f" "$f" done.Extract the original video, frame by frame, into PNG files:.I don't have a good solution for this, but here's my workaround. Because the overlay filter itself uses a lossy encoding during the process, the image quality will certainly degrade after overlay however this degradation usually won't be noticeable, and this filter is well suitable for most videos.īut if your input files are already in lossless formats, and if you absolutely want a lossless result, then don't use the overlay filter. Unfortunately it is not possible when using the overlay filter (at least with FFmpeg version 4.1.6-1~deb10u1 that I uses), even you use a lossless encoder for the final output file. Use CSS or your player to add the watermarkĪvoid encoding completely and just deal with the watermark with CSS or with your HTML5 video player. The output file size can be huge–generally much bigger than your input file. -codec:v libx264 -crf 0 -preset veryslow.vf format=yuv420p uses a compatible chroma subsampling required by most players.Īlthough you must re-encode for filtering it does not mean that you have to lose quality. preset controls encoding speed and therefore compression efficiency: ultrafast, superfast, veryfast, faster, fast, medium (the default), slow, slower, veryslow. crf controls quality: range is a log scale of 0-51, 0 is lossless, ~18 is often considered visually lossless, and 23 is default. Example for H.264: ffmpeg -i input -codec:v libx264 -crf 18 -preset slow -vf format=yuv420p out.mp4 Lossy, but looks losslessĪlternatively you can use proper encoding settings that look "visually lossless", but technically are not truly lossless. This is why -codec copy does nothing for you. Therefore any attempt at stream copying while filtering will be ignored. You must re-encode to perform any filtering
