What is the best way to convert a mp4 file to webm without quality loss (using vp8 or vp9) with ffmpeg?

If I do ffmpeg -i in.mp4 out.webm the quality is very bad. I can specify a target bitrate via -b:v and constant quality mode via crf, i.e.

ffmpeg -i in.mp4 -crf 10 -b:v 1M out.webm

This gives better quality. However for this I have to lookup the bitrate of the input video (here 1M).

I also noticed that if you specify a much larger value for the target bitrate than the bitrate of the input (here for example -b:v 100M), ffmpeg just seems to use approximately the bitrate from the input video with vp9 or slightly higher bitrate with vp8. However this solution doesn't seem to be the intended way to do this.

How would you choose the crf value and why?

Is there a parameter which automatically chooses the bitrate of the input file and a suitable crf value to get the same quality as the input file?

  • Set bitrate to 0. And experiment with crf. But your method of a high bitrate works too, since the value acts as a ceiling not a target – Gyan Oct 15 '16 at 18:22
  • 1
    @Mulvya: Does bitrate 0 mean that there is no limit? I didn't find this in the man page. – student Oct 15 '16 at 19:21
  • With bitrate not set to zero, CRF is constrained by that value. With zero, it's not. It's a quirk of the VPn encoders. – Gyan Oct 17 '16 at 3:14
  • Ok, but if I omit the bitrate parameter completely the quality gets very bad even thoug I didn't give an upper limit for the bitrate. – student Oct 17 '16 at 11:57
  • 1
    Link for 200k (see first option). For WebM b:v 0, see this page. – Gyan Oct 17 '16 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.