0

I gathered the following rate control algorithms are commonly used when encoding modern video formats like h264, HEVC or VP9.

  • With a constant quantizer (-qp in terms of ffmpeg) all frames are encoded with the same compression ratio. Any still frame one would extract from the resulting video should come out to the same visual quality, regardless of how movement-intense or complex of a scene it is from.
  • A constant rate factor (the -crf parameter) applies more compression to complex parts to in turn leave simple scenes relatively uncompressed. Thus more artifacts are introduced in e.g. quick moving shots, which in common application is less noticeable to the human eye, achieving a good subjective quality while saving on file size.
  • The third variant is to target a specific file size with two passes of variable bitrate (-b). The first pass collects data on each frame, so that the second pass then can allocate more bits to the parts of the video that are hard to retain quality otherwise. This effectively does the inverse of CRF, assigning more quality to complex scenes.

I am looking for a strategy to archive videos wherein the movement-heavy scenes are actually most important, may even be stopped, zoomed in on and analyzed for details, whereas slow or static content is less of interest. Am I right to look to two-pass VBR to achieve the best encoding in this regard?

Should my understanding of any of the above methods be mislead in the first place, feel free to correct me. Other hints for encoding movement with good quality are also appreciated. I am especially unsure whether two-pass variable bitrate indeed leads to a heavier distribution of bitrate towards quick scenes and would appreciate if someone could confirm this with any documentation.

1 Answer 1

0

Here is my understanding of FFMPEG, there are 4 settings for VQ, and they are "codec", "crf", "preset", and "tune". For the "codec", FFMPEG does not do well on VP9; the others are H.264 and H.265. For the "tune", i prefer "film" for H.264 and "grain" for H.265. "crf" and "preset" can get the VQ excellent but there are drawbacks:long encoding time and large file size (bitrate)

"codec" takes care of the bitrate, H.265 has smaller file size(bitrate) that retains same level of VQ but longer transcoding time.

"crf" takes care of the quantization and the bitrate, the smaller the crf, the better the video quality, but the longer the transcoding time, and larger the file size.

"preset" takes care of the bitrate, the slower the preset, the smaller the file size(bitrate), but the longer the transcoding time

Get back to your scenario - the quick movement video, we concern with the high frequency content. We don't want to see blocky images; therefore, we need higher bitrate, but we want reasonable transcoding time.

Therefore, i prefer H.265 "codec" and "tune" grain. Then we need to tweak the "crf" and "preset" based on the SSIM and PSNR results. I had done some experiments on the MainConcept sample stream (1080p content)

  • Default) codec=h.264 crt=23, preset=medium, the transcoding took 27.9s the bitrate=3118kb/s, the SSIM=0.994413, PSNR=48.644
  • Setting 1) codec=H.265, crt=23, preset=medium, tune=grain, the transcoding took 130s, the bite 3949kb/s, the SSIM=0.99487, PSNR=50.894298
  • Setting 2) codec=H.265, crt=1, preset=medium, tune=grain, the transcoding took 202.37s, bitrate=60883kb/s, SSIM=0.999738, PSNR=65.497223
  • Setting 3) codec=H.265, crt=23, preset=slow, tune=grain, the transcoding took 329.36s, bitrate=4338kb/s, SSIM=0.9952, PSNR=51.452838

Setting 3) has better VQ performance with acceptable drawbacks or you may keep tweaking the "crt" and "preset" to get to the point that reaches your acceptable transcoding time and the bitrate results.

Good luck!

2
  • Time is not of the matter: I can run all encodes with -preset veryslow. I appreciate the idea that -tune grain could indeed improve quick scenes and will experiment with that. In addition, I would be strongly interested in how I can configure a variable bitrate encoding that indeed distributes more bitrate to or dials up quality in quick scenes. Perhaps you or someone else can elaborate on this.
    – XZS
    Commented Nov 1, 2020 at 17:45
  • Those commands are vbr, Streams with no motion - no motion vectors & residual - low bitrate Streams with motion - yes motion vectors & residual - high bitrate Not sure what do you want to achieve here?
    – xer-rex
    Commented Nov 2, 2020 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.