How can I do that?
ffmpeg -y -i input.mp4 -vcodec libwebp -lossless 0 -compression_level 0 -loop 0 output_lossless0_comp0.webp
and
ffmpeg -i input.mp4 -vcodec libwebp -filter:v fps=fps=20 -lossless 0 -compression_level 3 -q:v 70 -loop 1 -preset picture -an -vsync 0 -s 800:600 output.webp
lead to substantial quality loss.
All other command lines i found elsewhere lead to infinite encoding times and absurd file sizes (500+ MB when the source is 3 MB).
All i need is to convert mp4 to webp without compression or quality loss.
Only -c:v copy
option can guarantee similar size of the output with no loss in quality, but webp
does not support mp4
codecs so you need to use "some" encoder and any encoder will lead you to a loss in quality or much bigger size of the output file (it's a tradeoff).
If you use libwebp
(documentation) then you will need to experiment with the different values of its parameters to get the result that will be good for you in terms of size, quality and time.
I would start any tests with -lossless 0
or -lossless 1
together with a different values for -compression_level
parameter:
For lossy, this is a quality/speed tradeoff. Higher values give better quality for a given size at the cost of increased encoding time. For lossless, this is a size/speed tradeoff. Higher values give smaller size at the cost of increased encoding time. More specifically, it controls the number of extra algorithms and compression tools used, and varies the combination of these tools. This maps to the method option in libwebp. The valid range is 0 to 6. Default is 4.