Re: [mediacapture-record] Rate control

Constant quality would be really useful. Given the option, I don't see why anyone would want to use cbr or vbr rather than constant quality for MediaRecorder.

CRF is supported by h264, libx264 and h265 (I don't think any browser can record with h265 currently, but that could change if Safari implements MediaRecorder). ffmpeg also supports crf for vp8 and vp9 (unlike libvpx/vpxenc). I don't know about av1, but I'm guessing the arguments will be similar to vp9.

As has been pointed out CRF is not consistent between codecs:
* CRF in h264 and h265 uses a range of 0-51. It's exponential, and "increasing the CRF value +6 is roughly half the bitrate while -6 is roughly twice the bitrate" ([source](https://trac.ffmpeg.org/wiki/Encode/H.264#crf)).
* For VP8 and VP9 the range is 0-63, though VP8 can't use 0-3 ([source](https://trac.ffmpeg.org/wiki/Encode/VP8#VariableBitrate)). I couldn't find much information about it. It seems to me that "CRF" in ffmpeg uses libvpx's`--cq-level` underneath.
* Rates in h264 and h265 correspond to bitrates rather than quality. "The CRF of 28 [encoding with h265] should visually correspond to libx264 video at CRF 23" ([source](https://trac.ffmpeg.org/wiki/Encode/H.265#ConstantRateFactorCRF)). I would expect VP8/VP9 to differ as well.

All of this makes it impossible to abstract CRF into a consistent cross browser standard without doing something ridiculous like standardizing and maintaining implementation details for each codec. But at least that's one less aspect to discuss.

Spec suggestions:

* Add 1 new quality parameter to [MediaRecorderOptions](https://w3c.github.io/mediacapture-record/MediaRecorder.html#mediarecorderoptions-section)
* Since the scope of the quality rate we're discussing applies to video only, the parameter name should start with "video", consistently with "videoBitsPerSecond". Ex "videoQualityRate".
* "videoQualityRate" should map to the codec quality rate parameter (ex: crf or cq-level)
* If specifying both "videoQualityRate" and (video)bitsPerSecond", bitsPerSecond should act as a fallback for codecs (and browsers) lacking support for quality rate.
* Throw a helpful error if specifying videoQualityRate in [MediaRecorderOptions](https://w3c.github.io/mediacapture-record/MediaRecorder.html#mediarecorderoptions-section), but codec is missing from mimeType (to avoid unexpected surprises in other browsers and/or when browsers change default codecs)

(I have no corporate affiliations and my suggestions are royalty-free)

-- 
GitHub Notification of comment by friday
Please view or discuss this issue at https://github.com/w3c/mediacapture-record/issues/57#issuecomment-334037844 using your GitHub account

Received on Wednesday, 4 October 2017 03:03:48 UTC