digitalFAQ.com Forum

digitalFAQ.com Forum (https://www.digitalfaq.com/forum/)
-   Restore, Filter, Improve Quality (https://www.digitalfaq.com/forum/video-restore/)
-   -   Way to automatically control intermittent overexposure issues? (https://www.digitalfaq.com/forum/video-restore/8977-automatically-control-intermittent.html)

stevevid 09-04-2018 06:17 PM

Way to automatically control intermittent overexposure issues?
 
I have three DV-AVI videos that were given to me that are digitizations of some of my wife's parent's 16mm films from the 1950s and older. I have split the first video into multiple files because the levels varied wildly from scene to scene. Typically, a file holds a whole scene. Sometimes I had to break up a scene into more than one file.

Many of the scenes are badly underexposed. Some looked almost totally black. I have been able to improve many of the issues with the ColorYUV plugin in AviSynth. It was interesting to see that out of the darkest video I could pull out enough information to see people and things that my wife recognized from when she was a kid. The histograms showed almost no data in them. My wife was speechless when she saw people and places she hadn't seen in over 55 years. Here's a big hell yeah to DigitalFAQ for providing the information to make this happen!:congrats:

There are still issues where the ColorYUV settings work with most of a scene then something changes that drives the white levels into the wall and probably through it. For example, an indoor scene of someone on the floor about 8feet away then someone else walks into view between the camera and the primary subject. The new person is brightly lit because they are closer to the fill light on the camera. The other parts of the image are ok. Is there a way for a script/plugin to automatically and non-linearly control the white level beyond a point such as 220 so the level doesn't hit the wall?

BTW, I used AvsPmod. It helped a lot to see a frame and have histograms for Y, U, and V. I could make script changes then click on the image to update the picture and histograms. I also used multiple tabs where each tab represented different level settings. It was fast and easy to switch between different tabs/approaches and see the effect. I saved a set of tabs for a scene as a named "Session." AvsPmod was awkward at first until I learned to save a session with a name similar to a scene name. I then cleared the tabs showing in AvsPmod before starting a new session or opening an existing session. If you load a session while the tabs from the prior session are still showing, AvsPmod will just add the tabs to the existing tabs.

Thanks!
Steve

sanlyn 09-04-2018 06:26 PM

Can't offer much advice without an unfiltered sample.

ColorYUV is useful but limited, works best with Avisynth contrast mask filters that help a lot, along with plugins like HDRagc and others.

Automatic? No such thing. But a workable sample would be far more helpful than a long description. The biggest problem with with underexposure is that crushed darks are mostly noise, really tough to clean.

lordsmurf 09-04-2018 06:27 PM

Not really.
At best, you can try to auto white balance Avisynth filter (in YUY2 colorspace). Results will vary. Try it.

Code:

ColorYUV(autowhite=true) # auto white balance
And I always use AvsPmod, both the x86 and x64 versions (for x86/x64 Avisynth, respectively).

sanlyn 09-04-2018 07:28 PM

Autowhite is the wrong filter for the problem described. It also crushes blacks and blows out highlights.
This is pure blind-shooting guesswork anyway without a sample.

stevevid 09-04-2018 08:36 PM

5 Attachment(s)
Here are samples!

The Outside clips are from the same scene. Each clip has a variety of exposures. I adjusted levels for one part which then didn't work at all for another section of the scene.

The snow clip is from Dallas. Yep, we used to get snow every year. Now, not much.

I think the Super Dark Clip came from the Adams Family or Munsters home movies.

At least my VHS captures aren't near as bad as these film videos. Whatever I learn here should go a long way to helping me process the VHS videos.

Thank you very much for your help,
Steve

themaster1 09-05-2018 07:52 AM

Work with sony vegas that's the best advice i can give. You can work scenes by scenes and use videoscopes (totally needed when you work with such sources). You can also pre process with avisynth

example of 2 scenes i tweaked with sony vegas
https://mega.nz/#!UlxhBYgR!5Vi96Oigk...guroOf_mA5d2jo

lordsmurf 09-05-2018 09:23 AM

I use Premiere.
Vegas admirable option.
And then the DaVinci Resolve is now freeware, worth a look.

@themaster1, I really wish you'd attach samples here, 99mb max (plenty enough space for a mere sample). Many of us don't use Mega. At a later date, the file will disappear, and long-term usefulness of the thread is decreased. :(

stevevid 09-05-2018 01:47 PM

themaster1, thank you for the reference to Sony Vegas. I'll take a look. Also,thanks for taking the time to create a cleaned up version of the video. I used your clip to compare to my pitiful one line AviSynth script. It gives me ideas of what I need to change and add.

LS, thanks for the reference to DaVinci Resolve. I'll check it out.

Any further thoughts on AviSynth and VD solutions?

hodgey 09-05-2018 02:22 PM

Quote:

Autowhite is the wrong filter for the problem described
Autogain may be what he meant, which does adjust levels, though very primitively.

Autolevels and AutoAdjust are slightly more advanced plugins that can do level adjustment more smoothly. They are still not very smart though, and can easily produce bad results.

sanlyn 09-05-2018 04:34 PM

6 Attachment(s)
Quote:

Originally Posted by stevevid (Post 55878)
themaster1, thank you for the reference to Sony Vegas. I'll take a look. Also,thanks for taking the time to create a cleaned up version of the video. I used your clip to compare to my pitiful one line AviSynth script. It gives me ideas of what I need to change and add.

LS, thanks for the reference to DaVinci Resolve. I'll check it out.

Any further thoughts on AviSynth and VD solutions?

Lots of thoughts, but none having much to do with Vegas. The DV genius who worked your original sources apparently assumed a camera frame rate of 14.985 fps -- which is what you get when you remove the pulldown (telecine) fields and duped and tripled frames from the samples. I've no idea how those repeats and pulldown patterns were derived. The "Super dark clip.avi" also had some dropped frames periodically, which made the jerky playback worse.

Digital video has a far more limited contrast and color range than film. You get to a certain level of darkness where digital values go to zero, and below that there's nothing. Nada. Just zero's, which to most of us means pure black. And no detail. None. Everything below a certain level gets destroyed. Gone. Kablooey. If you try to brighten it, what you get is random, black-speckled noise.

Here's an original frame 94 from your super dark sample:
http://www.digitalfaq.com/forum/atta...1&d=1536181469

YUV histograms of that frame tell a story about you can expect from the darkest areas:
http://www.digitalfaq.com/forum/atta...1&d=1536181554

In the histogram at the top left,m note the sharp white "spike" in the upper left corner. That spike indicates all the data which has effectively been converted to zeros or near-zeros. The remains of the white band say that there's sparse data in the rest of the image. The histogram in the middle says that almost all the image data is crushed against the left (black) border. The vectorscope on the right shows that all you have for chroma is a pathetic little lump near the center (gray).

I got the following from that frame with Avisynth and VirtualDub:
http://www.digitalfaq.com/forum/atta...1&d=1536181941

You can likely tweak here and there to get whatever you can. But in the above image, note the murky noise in the darkest shadows (under the parked car, in the tree shadows in the background and on the right). You'll see some black specks in there and some macroblock noise. You can make that noise brighter or darker, but you can't make it go away. Those black specks mean no data. You can't create details where none exist. The missing details show up as odd-looking facial features and other ill-defined objects. And digging through DV compression loss doesn't profit much.

The attached mp4 is a square-pixel 14.985 fps version of the filtered video. The scripts I used required two steps and some VirtualDub filters for tweaking. After I cleaned up the progressive version I used an encoder to insert pulldown in the attached DVD (MPG) telecine version. Pulldown flags were embedded by DGPulldown, which sad to say won't allow 15fps but insists on an 18fps base as its slowest input, so the 29.97 fps mpg looks a little faster than the mp4.

You can't use 15fps for a DVD for the family. And you can't do much cleanup with a combination of telecine and doubled-up/tripled-up frames, which simply won't work with temporal filters. I also did away with 3 or 4 bad frames. There's no auto way to calm down one wildly blown-out frame; no such filter exists.

Code:

#----------- STEP 1 SCRIPT ----------------#
#--- AviSource is "Super dark clip.avi" ---#
#------------------------------------------#

AssumeBFF()
TFM(pp=0).TDecimate(cycle=20,CycleR=10)

ColorYUV(gain_y=50)
ContrastMask(enhance=9.0)
AutoAdjust(high_quality=true,auto_gain=true,dark_limit=10.0,\
  gamma_limit=1.5,dark_exclude=0.25,gain_mode=0,chroma_process=200,\
  auto_balance=true,chroma_limit=2.0)

QTGMC(InputType=3,preset="slow",EZDenoise=8,denoiser="dfttest",\
  ChromaNoise=true,DenoiseMC=true,sharpness=0.75)

ConvertToRGB32(interlaced=false)  #<- for Virtualdub filter tweaks

#---  Output is 15fps progressive (14.985 fps).  ---#
#---  After VirtualDub filters are applied, save  ---#
#---  as Lagarith Yv12, for input to Step 2.      ---#

STEP 2:
Code:

#--- AviSource is YV12 AVI from Step 1 ---#
#-----------------------------------------#

DeBlock()
TemporalDegrain()
#--- Delete frames 13, 14, 15 ---#
S1=Trim(0,12)
S2=Trim(16,0)
return S1+S2

A VirtualDub .vcf file that sets up the VDub filters and settings I used is also attached. The filters used were gradation curves, ColorMill, and the VDUb Levels GUI.

sanlyn 09-05-2018 05:08 PM

6 Attachment(s)
Thanks for your samples, by the way.

The next sample I cam to was "Outside variable light 2.avi", which at least had some workable levels but godawful color. I didn't see much of a levels change between the two shots. There are a couple of blown-out bad frames, but unless you want to be fooling with them between now and this time next year you're better off letting them drop by the wayside, which is what I dd.

The big problem with the originals is overblown red and some really pumped black levels. Did the original film's black levels look like this original frame?
http://www.digitalfaq.com/forum/atta...1&d=1536184547

I kept the histogram showing in the frame while I jockeyed with the filters until I got what I wanted:
http://www.digitalfaq.com/forum/atta...1&d=1536184582

Then I ran a few Avisynth and VirtualDub tweaks, especially to get rid of some of the spots on the boy's clothes. There are filters around for film scratches. But before you try them, be aware that they're, inefficient in removing scratches but are gangbusters at destroying detail.
http://www.digitalfaq.com/forum/atta...1&d=1536184764

The attached mp4 is the square pixel 15fps version for the internet and USB players. The MPG is the DVD-encoded 29.97 fps version. There is also a .vcf file attached with the VirtualDub settings (the plugins used were Color Camcorder Denoise, gradation curves, and ColorMill).

Code:

#--- AviSource is "Outside variable light 2.avi" ---#
#---------------------------------------------------#

AssumeBFF()
TFM(pp=0).TDecimate(cycle=20,CycleR=10)
ColorYUV(off_u=12,off_v=-12,off_y=-35,gamma_y=-25)
Tweak(cont=1.25,sat=2.0,dither=true,coring=false)
AutoAdjust(high_quality=true,auto_gain=true,dark_limit=1.0,\
  gain_mode=1,chroma_process=200,auto_balance=false)
# Histogram("Levels")  #<- for initial settings only
# return last          #<- for initial settings only

RemoveDirtMC(40,false)
ReplaceFramesMC2(15,1)
ConvertToRGB32(interlaced=false)  #<- for VirtualDub filter tweaks)
S1=Trim(0,52)
S2=Trim(55,0)
return S1+S2

#--- Output is progressive 15fps (14.985 fps).    ---#
#--- After  VirtualDubb filters are applied, save ---#
#--- VDub output as Lagarith YV12 for encoding    ---#
#--- and resizing later.                          ---#

Pulldown for 29.97 for NTSC DVD was added by the encoder.

sanlyn 09-05-2018 06:08 PM

5 Attachment(s)
The last sample I had time for was "Outside variable light 1.avi". For other samples I used SmoothAdjust for one of those contrary auto level filters (all of which still need massaging with other filters),m but for this sample I used HDRagc. The main reason was that SmoothAdjust didn't do what I wanted. HDRagc didn't exactly do what I wanted either, but it got closer than the others I tried. In any case, whenever you deal with these automatons be prepared for long and tiring compromise.

The two images below are from the original .avi. In this sequence the girl runs from the left image into the right image, from a darkly shaded area to bright sunlight. Naturally, you expect the levels to change. Here, they changed quite a bit from left to right.
http://www.digitalfaq.com/forum/atta...1&d=1536187879

The temptation is to make t he image on the left as bright as the image on the right. That wouldn't be correct -- heavy shade never looks like bright sunlight. And anyway, the filters often don't read your mind and will do whatever they want. The image below is the compromise I reached with HDRagc and some help from other filters:
http://www.digitalfaq.com/forum/atta...1&d=1536188105

The left side looks about right, but the right side is a bit bright, gamma is higher, it looks brighter during playback, and some of the hues are changed. Well...you can't have everything. That's especially true when the same filter settings simply won't cooperate with every scene that comes along. One-size-fits-all just doesn't work with video cleanup.

The script below creates three different scene changes and processes each separately, then joins them.
Code:

#--- AviSource is "Outside variable light 2.avi" ---#
#---------------------------------------------------#

AssumeBFF()
orig=last

#--- Routines for Scene 1 ---#
orig.Trim(0,104)
HDRagc(coef_gain=2.5,corrector=0.55)
SmoothLevels(24,1.1,255,16,255)
Tweak(sat=1.2,cont=1.05,coring=false,dither=true)
S1=last
# Return S1    #<- setup test only

#--- Routines for Scene 2 ---#
orig.Trim(116,409)
HDRagc(coef_gain=2.5)
ContrastMask(enhance=3.0)
Tweak(cont=1.1,coring=false,dither=true)
ReplaceFramesMC2(195,1)
S2=last
S2a=S2.Trim(0,218) + S2.Trim(223,292)
# Return S2a    #<- setup test only

#--- Routines for Scene 3 ---#
orig.Trim(412,0)
HDRagc(coef_gain=2.0,corrector=0.8)
ColorYUV(off_y=-12,off_u=2)
Tweak(cont=1.25,coring=false,dither=true)
SmoothLevels(32,1.0,255,16,255)
S3=last
# Return S3    #<- setup test only

#--- Join all 3 Scenes ---#
S123=S1+S2a+S3
S123
SeparateFields()
e=SelectEven().RemoveDirtMC(40,false).TemporalDegrain()
o=SelectOdd().RemoveDirtMC(40,false).TemporalDegrain()
Interleave(e,o)
Weave()
ConvertToRGB32(interlaced=true)  #<- for VirtualDub filter tweaks
return last


#--------  Output is interlaced 29.97 fps.  ---------#
#--- After VirtualDubb filters are applied, save  ---#
#--- VDub output as Lagareith YV12 for encoding  ---#
#--- and resizing later.

After running this script and creating the interlaced DVD, I had to run the results of that script through another script, to create the 640x48-0 15fps mp4. Deinterlace/de-telecine and resize script:

Code:

#--- AviSource is previous interlaced 29.97 fps AVI ---#
#------------------------------------------------------#

AssumeBFF()
TFM(pp=0).TDecimate(cycle=20,CycleR=10)
Spline36Resize(640,height)

#--- Output is 640x480 YV12 progressive 14.985 fps---#

The .attached .vcf file has the VDub filter settings (Color Camcorder Denoise and SmartSmoother).

stevevid 09-06-2018 12:05 AM

Sanlyn, thanks for all the work you did. I had a reply almost ready when the "Reply to Thread" editor started acting strange. I deleted one word and all text but one line were erased. The editing part of preview post did not show my images but the part above the editing window did show the images. I totaly gave up when the preview editing window started inserting duplicates of my images. I'll try again tommorrow.

stevevid 09-14-2018 09:15 PM

Where can I find "ContrastMask" that is used in post 10? It appears to be a script, but I have found references to different versions for video. AviSynth's wiki doesn't have any information.

Sanlyn, I'm looking at your VirtualDub settings from post 10. What does the Levels filter add that improves the image? The setting seems to darken the image.

Thanks,
Steve

-- merged --

I found a ContrastMask in an attachment list I found in the thread Video restoration newbie: Avisynth scripts? Sanlyn is this the file you used or is there a different one?


All times are GMT -5. The time now is 09:22 AM

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.