2
I am working at a raw to timelapse program, and I am using ffmpeg to generate a video out of a sequence of JPGs that my program outputs.
The user can select from different codecs, such as libx264, mjpeg, vp8, vp9.
I am having good results with h264 and mjpeg, but vp8 gives me some very bad quality videos, even though I set the quality pretty high, and the file size is comparable to h264 videos.
I am using the following settings:
ffmpeg.exe -framerate 12 -i "./output/img_%05d.jpg" -dst_range 1 -color_range 2 -c:v libvpx -b:v 0 -threads 8 -speed 2 -crf 8 "./output/video.webm"
You can see a sample video here: https://www.youtube.com/watch?v=eG2jxzR3Uxs (the encoding problems are mostly visible after 9 seconds).
Someone at Stack Overflow said that VP8 needs two passes, but this is unpractical. Is it any way to get good results in a single pass? Something comparable to h264 in terms of size/quality?
-b:v 0
? Seems you have set the bitrate to 0 for some reason... – Arete – 2017-12-26T22:18:04.813That is needed to use -crf – Radu – 2017-12-26T22:23:33.833
Hmm, it seems the v:b 0 was for VP9 encoding. I'll run some tests with set rates. – Radu – 2017-12-26T22:30:37.207
You can also set quality with the
– Arete – 2017-12-26T22:31:57.230-quality
variable. Here is a great guide.Thank you, it seems that the b:v 0 was the problem. I assumed that, like vp9, it will automatically select whatever rate would match the best compression. Please post it as an answer, so I can mark it as solved. – Radu – 2017-12-26T23:22:08.863
2Someone at Stack Overflow, for context, is Ronald Bultje, who maintains the libvpx wrappers in ffmpeg. – Gyan – 2017-12-27T11:04:34.003
@Radu Can you link the thread or edit your question to include it? I would be interested in the 2-pass answer but I'm having trouble finding it. – glenneroo – 2018-06-29T23:30:29.340
Hi, it was this thread: https://stackoverflow.com/questions/47965327/ffmpeg-encoding-with-vp8-producing-bad-looking-video
– Radu – 2018-07-01T00:59:48.393