Auto contrast adjustment for H.264

Started by c2s07, February 01, 2019, 06:39:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

c2s07

Here is what I would like to be able to do in ML.

I tend to record videos with minimal contrast in picture style, HTP enabled, and enhancing contrast by stretching levels in post-processing* on the compressed data. But as the compressed data is only 8 bits in bit depth, I've been wondering if it would be possible to do this in-camera, just after picture style is applied. If I recall correctly, the bit depth is still 10 bits / channel at this point. I have some programming experience, but my educated guess would be that this sort of thing is undoable in ML even if I had all the programming experience in the world?

I know we can write LUA scripts, but my understanding is that the scripts can only operate the camera when it is in an 'idle' state, by which I mean that the camera is not currently exposing a still frame, or recording a video clip.

Otherwise, if possible within reason, I'd be interested in looking into this...

* (Avisynth scripting)

a1ex

Maybe I didn't understand the question, but... if you increase the contrast in the picture style, wouldn't that give exactly the result you are trying to get?

Or, are you trying to find the maximum contrast that's not going to clip anything, i.e. scene-dependent? Or, even better, some sort of automatic exposure + contrast + saturation (possibly other post-processing parameters) optimized for H.264 recording?

I'd probably go for:
- ETTR (optimal exposure for RAW, but not necessarily with H.264)
- digital gain (you can use strong negative values if and only if the raw image is not clipped)
- *maybe* some sort of deflicker, if it can be implemented in realtime (histogram-based)
- maximize contrast/saturation in picture style settings as long as the YUV values (or possibly RGB values after conversion) are not clipped*) (otherwise, keep them to minimum)

*) ... except maybe a very small area, i.e. allow specular highlights.

Definitely not a trivial task, especially if you want it to work out of the box with unpredictable lighting conditions.

c2s07

Yes, I think you understood the question: maximizing scene-dependent contrast. It's the varying lighting conditions that pose the problem. During continuous video recording, I can't fix and maximize the contrast for some low-contrast scene such as when the sun is behind my back, because if I turned the camera to face the sun, a lot of shadow/highlight details would then be lost to clipping.

So in this sense, the static picture style contrast is a bit inpractical. Instead, it would have to be adaptive; evaluated for each video frame*, auto-adjusting itself in very fine steps (so that the viewer doesn't see when the value is changed) in order to maximize contrast without causing clipping. But now I seem to recall some discussions on these forums, stating that ML cannot have very fine control over the picture style settings and the internal values they use?

* The ML histogram seems to be already making the statistical calculations to find out how severely the highlights are clipped, so at least the calculations shouldn't be too heavy.

mothaibaphoto

@c2s07: You just described how Auto Lighting Optimizer works.

c2s07

Well, ALO can increase the contrast somewhat, but it's not going to maximize the output range like how "auto levels" in Photoshop works, which is essentially what I'm currently doing in postprocessing.* Furthermore, ALO cannot seem to be enabled in M-mode or when Highlight Tone Priority is active, both of which I use.

* By the way, there is a difference between increasing contrast by modifying the tone curve, and by stretching the levels; I think the latter should be tried first, though in some cases it shouldn't be taken to the extreme.