ffmpeg mp4 to gif retain quality code example
Example: merge gif with mp4 using ffmpeg
ffmpeg -i input.mp4 -i eq.gif -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.5[front];[0][front]overlay=x=(W-w)/2:y=H-h,format=yuv420p" output.mp4
ffmpeg -i input.mp4 -i eq.gif -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.5[front];[0][front]overlay=x=(W-w)/2:y=H-h,format=yuv420p" output.mp4