VideoHelp Forum
+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 32
Thread
  1. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    I’ve been working with a slideshow program & trying to figure out how TV safe colors work. So I did some .jpg frame captures of the slideshow.

    Out of curiosity I also checked colors on a couple DVDs I had recorded with a stand alone DVD recorder and using cable TV as the source. What I was able to frequently find were RGB values from 1,1,1 to 255, 255, 255 within the picture area. And sometimes within the same frame. In other words the NTSC compliant videos did not adhere to the safe color range of 16,16,16 to 235, 235, 235.

    Am I misinterpreting how safe colors work? If they are not used on the DVDs I recorded, when are they used?
    Quote Quote  
  2. Most software will convert YUV to RGB with the standard rec.601 or rec.709 conversion matrix. This expands the luma 16-235 range to 0-255 RGB. This is because in YUV video 16 is black and 235 full white, whereas in computer RGB 0 is black and 255 is white.

    If you want to see what the real luma range in the video is you must use a pc.601 or pc.709 matrix which doesn't perform the contrast expansion.

    Conversely, most software will convert RGB 0-255 to YUV 16-235.
    Quote Quote  
  3. ...So I did some .jpg frame captures of the slideshow.
    With which program? Maybe this program does already some kind of a range expansion. On a 'real' DVD the colors are not coded as RGB values but as YCrCb values.
    Quote Quote  
  4. As noted, most programs expand the contrast when converting YUV to RGB, and compress the contrast when converting RGB to YUV.

    Here's an MPEG elementary stream with the full luma range from 0 to 255:

    r0-255.m2v

    On a properly calibrated player and TV you should not be able to see the difference between the areas marked 16, 12, 4, and 0 (they should all be black). You can often see a difference between the areas above 235 depending on the TV.

    If your software expands luma 16-235 to RGB 0-255 it will look like this:



    If your software doesn't expand the contrast it will look like this:

    Quote Quote  
  5. Member
    Join Date
    Aug 2005
    Location
    Palo Alto, California USA
    Search Comp PM
    Nice job, jagabo -- that has helped educate many people besides the OP!
    Quote Quote  
  6. Converting to animated gif loses a little precision but you can still see the difference:



    Notice how the whites above 235 become totally white and the dark grays all go completely black when the contrast is expanded. Note that normal YUV video should not have luma below 16 or above 235 so the contrast expansion isn't a problem when converting to RGB.
    Quote Quote  
  7. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    Thanks jagabo for all the information.

    Here's what I've been working with. I made a black .jpg (0,0,0,) and used this for a slide photo & also for the background/frame. The black background/frame appears black & matches the black pillar box side bars on my 16:9 TV. Essentially looks the same as a black movie title on the TV. However the black photo displays as dark gray. This is either viewing from the slideshow software on the PC monitor or from burning a DVD and watching on the TV. The photo & background are both created with the slideshow software. I previously adjusted my TV using a calibration DVD and have re-checked it.

    I did a frame capture from the DVD using VideoReDo TVSuite & used Photoshop Elements to look at the color values in the frame captures.

    The black border had values:1, 1, 1.
    The black image had values:14, 19, 15. Pretty close to 16,16,16.

    I also did a white with white DVD.
    White border: 255, 255, 255.
    White image: 255, 255, 255. This did not change to 235,235,235.

    I looked at a few DVDs that were recorded with a stand alone DVD recorder. A title is the easiest image to look at, but I did look at the movies too. A screen capture of a black movie title typically had black of 1,1,1 and white of 255,255,255.

    While the slides may have the correct safe black values, some of them look a bit too light. But broadcast movies have a darker black. How do they get away with using 1,1,1 for black?

    I presume my TV is displaying the 1,1,1 black as 16,16,16 black.

    If the slideshow changes my 0,0,0 black image to about 16,16,16, I would think it would also display as 16,16,16. But it is lighter. That would mean that the TV (and the PC) must be changing it.

    I've been presuming that a black color with RGB levels of 16,16,16 also means that the luma value is 16, but perhaps this is not the case. Can you please verify one way or the other?
    Quote Quote  
  8. Originally Posted by Mike99
    If the slideshow changes my 0,0,0 black image to about 16,16,16, I would think it would also display as 16,16,16. But it is lighter. That would mean that the TV (and the PC) must be changing it.

    I've been presuming that a black color with RGB levels of 16,16,16 also means that the luma value is 16, but perhaps this is not the case. Can you please verify one way or the other?
    The RGB range of 0 to 255 is compressed to luma values of 16 to 235 when converted to YUV for DVD (simplified: Y=RGB*220/256+16). So RGB=0 becomes luma=16. RGB=16 becomes luma=~30. RGB=255 becomes luma=235.

    Conversely, when the YUV is converted to RGB the 16-235 range is expanded to RGB 0-255. Y=16 becomes RGB=0, Y=235 becomes RGB=255, Y=0 would become something like -13 but you can go below 0 in RGB so it becomes 0 just like Y=16. Y=255 would become RGB=280 but you go above 255 so it is clamped to 255.

    Originally Posted by Mike99
    I looked at a few DVDs that were recorded with a stand alone DVD recorder. A title is the easiest image to look at, but I did look at the movies too. A screen capture of a black movie title typically had black of 1,1,1 and white of 255,255,255.

    While the slides may have the correct safe black values, some of them look a bit too light. But broadcast movies have a darker black. How do they get away with using 1,1,1 for black?
    They don't use YUV luma=1 for black. They use luma=16. It's the software you are using that's converting YUV luma=16 to RGB=1.

    Originally Posted by Mike99
    I presume my TV is displaying the 1,1,1 black as 16,16,16 black.
    Your TV should be displaying YUV luma=1 and luma=16 the same shade of black. RGB 1 and 16 should not appear as the same shade of black.

    If you know now to use AviSynth you can use the VideoScope() filter to display luma values while still in YUV space:



    I've added all the green arrows to show where different features of the video appear within the graph. For example, the smooth gray scale from black to white appears as the smooth diagonal line from bottom left to upper right. The 235 patch appears as a horizontal line. The 231 to 255 patches appear as shorter horizontal lines above and below the 235 patch. Keep in mind that normal video would not have those excursions above 235 (and below 16). Also note that I created this image using VirtualDub which performs the usual contrast expansion when converting YUV to RGB. So the RGB values are not the same as the source video's luma values and the bright and dark patches have been clamped.

    A DVD rip (Lost in Space trailer):

    Quote Quote  
  9. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    jagabo,

    Wow, thank you for all the information. I’m going to have study this a bit. I have only worked with Avi Synth a little bit but will look into the VideoScope() filter. I’m not a programmer but will try to figure it out.

    While I’m reading up on that, I have a question regarding Y=RGB*220/256+16).

    If the RGB levels are 4, 8, 16 for example, do I just add these up for a RGB value of 28 to use in the equation? Or average them for a value of about 9?

    Also, do you know where I might be able to get a mpeg file which has the luma values labeled as in your examples that can be burned a DVD? Unfortunately I was unable burn a DVD from the elementary stream file r0-255.m2v. The calibration DVD that I have does display many blacks & whites, but not their actual values.

    Thanks again.
    Quote Quote  
  10. Member edDV's Avatar
    Join Date
    Mar 2004
    Location
    Northern California, USA
    Search Comp PM
    The above is true for component YPbPr analog and YCbCr digital but analog NTSC and PAL have much reduced color gamut.

    Those who produce package advertising need expertise in matching Pantone colors to NTSC/PAL gamut. Clients are relentless in demands for perfect color match on reference NTSC monitors.

    For more detail you can't beat Charles Poynton's comprehensive FAQ's and books on TV color theory.

    http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html
    (Note in particular sections 28-31)

    http://books.google.com/books?id=ra1lcAwgvq4C&pg=RA1-PA234&dq=wavelength+beams+additiv...DDGjX8#PPP1,M1
    (See chapter 12 for NTSC and PAL -- unfortunately missing from this post)

    http://books.google.com/books?id=DL73f4vFeEwC&pg=PA179&dq=rgb++gamma+assumed&lr=&as_br...XfpQ#PPA107,M1
    (see chapter 1.9 pp-112-119)

    Formal I/Q "Legal" NTSC colors are restricted to the "N" triangle although in practice the EBU U/V "P" triangle is used today for NTSC equipment. Analog NTSC broadcasts must stay in this range.

    http://www.informationdisplay.org/article.cfm?year=2006&issue=05&file=art3

    http://displaydaily.com/2007/01/23/ntsc-color-gamut-be-gone-enter-xvycc-and-deep-color/

    More detail
    ftp://ftp.alvyray.com/Acrobat/Color78.pdf
    Recommends: Kiva.org - Loans that change lives.
    http://www.kiva.org/about
    Quote Quote  
  11. If you use the chapter editor from GfD (ChapEditGFD), you may easily switch contrast expanding on or off (activate/deactivate 'ScaleRGB'). With the r0-255.m2v file from jagabo the result looks exactly like in the posted images...
    Quote Quote  
  12. The equations use by most software for standard definition video are given in section 30 of Poynton's FAQ:

    http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC30

    Some practical information:

    http://forum.doom9.org/showthread.php?t=133982#post1090068
    Quote Quote  
  13. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    I’m reading through all the information & slowing digesting some of it. At the same time I’m trying to apply some of it to analyze why my black slides display as dark gray, even though their surrounding border/frame does display as black.

    I d/l VideoScope & read some information about it. It appears the VScope.dll file has to go into the AviSynth plugin folder, which I did. But where do the other VScope files go?

    The d/l comes with an “example2.avs” file that I cannot get to play. I have been using Windows Media Player 6.4.09.

    Any suggestions please?
    Quote Quote  
  14. Member edDV's Avatar
    Join Date
    Mar 2004
    Location
    Northern California, USA
    Search Comp PM
    Originally Posted by Mike99
    I’m reading through all the information & slowing digesting some of it. At the same time I’m trying to apply some of it to analyze why my black slides display as dark gray, even though their surrounding border/frame does display as black.
    ...

    Any suggestions please?
    How were these "slides" captured? Sounds like classic black to gray shift that results from NTSC capture from zero IRE instead of 7.5 IRE.

    Check the good old JVC black level tutorial. Wait for it to start. Takes a few seconds to load.
    http://pro.jvc.com/pro/attributes/prodv/clips/blacksetup/JVC_DEMO.swf
    Recommends: Kiva.org - Loans that change lives.
    http://www.kiva.org/about
    Quote Quote  
  15. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    Originally Posted by edDV
    Originally Posted by Mike99
    I’m reading through all the information & slowing digesting some of it. At the same time I’m trying to apply some of it to analyze why my black slides display as dark gray, even though their surrounding border/frame does display as black.
    ...

    Any suggestions please?
    How were these "slides" captured? Sounds like classic black to gray shift that results from NTSC capture from zero IRE instead of 7.5 IRE.

    Check the good old JVC black level tutorial. Wait for it to start. Takes a few seconds to load.
    http://pro.jvc.com/pro/attributes/prodv/clips/blacksetup/JVC_DEMO.swf

    I've been working on a slideshow which allows burning a DVD. I used a black .jpg for a slide photo & also for the background/frame. The black background/frame appears black & matches the black pillar box side bars on my 16:9 TV. Essentially looks the same as a black movie title on the TV. However the black photo displays as dark gray. This is when viewing from the slideshow software on the PC monitor or from a burned DVD and watching on the TV. The photo & background/frame are both created with the slideshow software, but they display differently.

    I did a frame capture from the DVD using VideoReDo TVSuite & used Photoshop Elements to look at the color values in the frame captures. Even if the capture is not accurate, there is still a situation where the same black jpg is displayed two different ways. Supposedly the slide images are using safe TV colors, but they are a bit too light or washed out. This is especially noticeable when looking at black.

    I used a calibration DVD to adjust my TV & have re-checked it. As an added note, black movie titles & backgrounds match & blend in with black letterbox & pillar box bars. IOW the picture is not too light.

    Please look at my earlier message for additional details that may be pertinent.

    Thanks.
    Quote Quote  
  16. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    I've had some success. Here’s what I got to work.

    I made a slideshow with 3 slides: black, white, black. I also used black for the background/frame.

    I saved as an .avs file. To the end of the file I added:

    ConvertToYUY2()
    VideoScope("bottom", true, "Y", "Y", "Y")

    When played back using Windows Media Player 6.4.09, I do get the graph at the bottom.

    Based on what I see on jagabo’s picture, the black background appears to be luma 16.
    The black slides appear to be luma 32 & the white slides luma 235. I’m guessing black level in the slide images is getting hit twice with an adjustment.

    Does the script appear to be proper?

    I’d like to post a picture, but from what I’ve read I need to put it up on a server. I’ll have to see what I can do.
    Quote Quote  
  17. You can post a PNG, JPG, or GIF image just by using the "upload image of file" option below the editing window here. Just make sure it's less than 6 MB.

    Your script looks fine for VideoScope(). I'm lazy and usually use the defaults (no arguments). I cut off the side graph on the images I posted.

    Did you use AviSynth's ImageSource() to create the slideshow? That would have given you RGB data. ConvertToYUY2() would compress the RGB contrast (0-255) to the valid YUV range (16-235). If you want to avoid the contrast compression use ConvertToYUY2(matrix="PC.601"). Going the other way around use ConvertToRGB(matrix="PC.601") to retain contrast levels.

    You can use Info() in your script to tell you the current (as of the line you add the command) colorspace:

    ImageSource(...)
    Info()

    Quote Quote  
  18. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    jagabo,

    I do not know how the program creates the video. I’m not a programmer, but I believe it needs AviSynth in order to work. You can burn a DVD directly from the program, or you can export a slideshow in several different formats, including an .avs file, which is what I did. While I can change the saved .avs file, I do not know how it was created in the first place.

    1) I added Info() to the end of the original .avs file and get ColorSpace: YV12.
    Black slide looks dark gray.

    2) If I change to ConvertToYUY2(), then it shows ColorSpace: YUY2.
    Black slide looks dark gray.
    VideoScope does work and shows the black background/frame at about luma 16, black slide at about luma 32, white slide at about luma 235. The background/frame & slide use the same black jpeg file. Therefore I would think they should display the same, but they don’t. This is what I don’t understand.

    3) Changing to ConvertToYUY2(matrix="PC.601"), I get an error message: ConvertToYUY2: invalid “matrix” parameter (RGB data only).

    4) Using ConvertToRGB(matrix="PC.601"), it shows ColorSpace: RGB32.
    Black slide looks dark gray.

    I read the slideshow program uses HCEnc and this needs YV12 input. Does YV12 use the same safe TV colors as YUY2?

    The three working versions all display the black slide as dark gray, but only version #2 provides the VideoScope in order to quantify it.

    First picture shows the black slide surrounded by the black background.

    Second picture shows the white slide surrounded by the black background.






    Quote Quote  
  19. Member edDV's Avatar
    Join Date
    Mar 2004
    Location
    Northern California, USA
    Search Comp PM
    Placing your charts on the DV timeline, Vegas shows center black at correct level 16 and border at sub-black digital zero.


    The white is showing at 255. Nominal white should be at 235 for DVD with transient excursions above.
    Recommends: Kiva.org - Loans that change lives.
    http://www.kiva.org/about
    Quote Quote  
  20. Originally Posted by edDV
    Placing your charts on the DV timeline, Vegas shows center black at correct level 16 and border at sub-black digital zero.
    That's because his image was converted to RGB with the usual luma expansion before saving as a jpg image. The Videoscope graph shows that the outer black box is at luma ~16, the inner box at luma ~32. The same is true for the white patch, before luma expansion it was ~235.
    Quote Quote  
  21. Originally Posted by Mike99
    I do not know how the program creates the video. I’m not a programmer, but I believe it needs AviSynth in order to work. You can burn a DVD directly from the program, or you can export a slideshow in several different formats, including an .avs file, which is what I did. While I can change the saved .avs file, I do not know how it was created in the first place.
    You need to post the entire AVS script. It's pointless to add Info() after an explicit ConvertTo...(). We already know what it's converting to. What we need to know is what it's converting from in the first place. Add info right after any import function ...Source(). Then we need to see exactly what's happening in the rest of the script.
    Quote Quote  
  22. Member edDV's Avatar
    Join Date
    Mar 2004
    Location
    Northern California, USA
    Search Comp PM
    Yes, the videoscope is showing the correct story per your vs.jpg chart.


    The vs chart above appears like this on a traditional waveform monitor.
    Recommends: Kiva.org - Loans that change lives.
    http://www.kiva.org/about
    Quote Quote  
  23. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    Here is the original, unmodified script. First part appears to load the background. Then a section about subtitles, which I did not use. Then it deals with the slide images (I used three) & transitions. But this is just my guess. To use the VideoScope, I added the following two lines to the very end.

    ConvertToYUY2()
    VideoScope("bottom", true, "Y", "Y", "Y")

    ----------------------------------------------

    # Script gererated by DVD slideshow GUI
    SetMemoryMax(round(SetMemoryMax(0)*0.5))
    loadplugin("C:\Program Files\DVD slideshow GUI\Transitions\TransAll.dll")
    loadplugin("C:\Program Files\DVD slideshow GUI\bin\vsfilter.dll" )
    loadplugin("C:\Program Files\DVD slideshow GUI\bin\zoom.dll")
    loadplugin("C:\Program Files\DVD slideshow GUI\bin\freeframe.dll")

    # Definitions:
    SafeH = 380
    SafeW = 576
    overimg=blankclip()
    SafeAviH = multifour(380) # resizing avis within width and height
    SafeAviW = multifour(576)

    # Import of background image - the proportions of this will be the proportions of the final film.
    bname = "C:\Program Files\DVD slideshow GUI\background_black.jpg"
    SafebH = 480 # resizing background within width and height
    SafebW = 720
    rate = 29.970
    bname = LanczosResize(imagesource(bname,1,1,rate),SafeBW,s afeBH)
    a = bname
    at = bname
    b = bname
    bt = bname

    Try {
    imgout=ImageSource("C:\Temp Video\black white black slide 9_temp_files\black white black slide 9%06d.ebmp", 0,3, rate)
    }
    Catch(err_msg) {
    imgout=blankclip(1,720,480, fps=29.970).converttoyv12()
    }
    SafeH = 480
    SafeW = 720

    # The filename and location of the exported ssa file with subtitle values for each text.
    ssa = ""
    writefilestart(blankclip(),"C:\Program Files\DVD slideshow GUI\DVDsGUItemp"+".ssa","ssa",append = false)
    ssafile = "C:\Program Files\DVD slideshow GUI\DVDsGUItemp_subtitles.ssa"
    ssa = ssa + "[Script Info]"+ chr(10)
    ssa = ssa + "ScriptType: v4.00"+ chr(10)
    ssa = ssa + "Collisions: Normal"+ chr(10)
    ssa = ssa + "PlayResX: 720"+ chr(10)
    ssa = ssa + "PlayResY: 480"+ chr(10)
    ssa = ssa + "Timer: 100,0000"+ chr(10)
    ssa = ssa + chr(10)
    ssa = ssa + "[V4 Styles]"
    writefilestart(BlankClip(),"C:\Program Files\DVD slideshow GUI\DVDsGUItemp"+".ssa","ssa",append = true)
    ssa = ""
    ssa = ssa + "Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, "
    ssa = ssa + "BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel,Encoding"
    writefilestart(BlankClip(),"C:\Program Files\DVD slideshow GUI\DVDsGUItemp"+".ssa","ssa",append = true)
    ssa = ""
    ssa = ssa + "Style: Default,Arial,39,16777215,65535,0,0,0,0,1,2,0,2,20 ,20,70,0,1"
    writefilestart(BlankClip(),"C:\Program Files\DVD slideshow GUI\DVDsGUItemp"+".ssa","ssa",append = true)
    ssa = ""+ chr(10)
    ssa = ssa + "[Events]"+ chr(10)
    ssa = ssa + "Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text"+ chr(10)
    writefilestart(BlankClip(),"C:\Program Files\DVD slideshow GUI\DVDsGUItemp"+".ssa","ssa",append = true)
    ssa = ""
    ssa = ssa + "Dialogue: 0,"+ convert2hhmmscff(0, rate)+ ","+ convert2hhmmscff(100, rate)+",Default,NTP,0000,0000,0000,!Effect,{\pos(3 60,420)}" + chr(10)

    # PROGRAM
    # Slide no:1
    inpoint = 1
    a = (trim(imgout,000001,000001))
    a = loop(a,100)
    at = (trim(imgout,000001,000001))
    at = TransPrep(at,25)
    a = audiodub(a,BlankClip(length=a.framecount, fps = rate, audio_rate=48000, stereo = true))
    at = audiodub(at,BlankClip(length=at.framecount, fps = rate, audio_rate=48000, stereo = true))
    outpoint = a.framecount+at.framecount

    # Transition no:1
    bt = (trim(imgout,000002,000002))
    bt = loop(bt,25)
    bt = audiodub(bt,BlankClip(length=bt.framecount, fps = rate, audio_rate=48000, stereo = true))
    at=at.SSRC(48000,fast=true)
    bt=bt.SSRC(48000,fast=true)
    ft=25
    c = (import("C:\Program Files\DVD slideshow GUI\transitions\Dissolve.avs"))
    c = audiodub(c,BlankClip(length=c.framecount, fps = rate, audio_rate=48000, stereo = true))
    d = a + c

    writefilestart(d,"C:\Program Files\DVD slideshow GUI\DVDsGUItemp"+".ssa","ssa",append = true)
    ssa = ""

    # Slide no:2
    a = (trim(imgout,000002,000002))
    a = loop(a,100)
    at = (trim(imgout,000002,000002))
    at = loop(at,25)
    a = audiodub(a,BlankClip(length=a.framecount, fps = rate, audio_rate=48000, stereo = true))
    at = audiodub(at,BlankClip(length=at.framecount, fps = rate, audio_rate=48000, stereo = true))
    outpoint = d.framecount+a.framecount+at.framecount

    # Transition no:2 - Stillimage
    bt = (trim(imgout,000003,000003))
    bt = loop(bt,25)
    bt = audiodub(bt,BlankClip(length=bt.framecount, fps = rate, audio_rate=48000, stereo = true))
    at=at.SSRC(48000,fast=true)
    bt=bt.SSRC(48000,fast=true)
    ft=25
    c = (import ("C:\Program Files\DVD slideshow GUI\transitions\Dissolve.avs"))
    c = audiodub(c,bt).eqaudio()
    d = d + a + c
    writefilestart(d,"C:\Program Files\DVD slideshow GUI\DVDsGUItemp"+".ssa","ssa",append = true)
    ssa = ""

    # Slide no:3 - last

    b = (trim(imgout,000003,000003))
    b = loop(b,100)
    outpoint = d.framecount+b.framecount
    b = audiodub(b,BlankClip(length=b.framecount, fps = rate, audio_rate=48000)).eqaudio()
    d = d + b
    d = pointchk(inpoint, outpoint) ? d : d.trim(0,inpoint)+audiodub(d.trim(inpoint,outpoint ),BlankClip(length = (outpoint-inpoint), fps = rate, audio_rate=48000)).eqaudio()
    writefilestart(d,"C:\Program Files\DVD slideshow GUI\DVDsGUItemp"+".ssa","ssa",append = true)
    ssa = ""
    last=0
    d.trim(2,d.framecount)

    #Functions:
    function TransPrep( clip TpClip, int TPLength)
    {
    TpFrames = TpClip.framecount()
    TpClip= (TpFrames-abs(TpLength)<0) ? TpClip+loop(trim(TpClip, TpFrames, TpFrames),(abs(TpLength+TpFrames))) : trim (TpClip, TpFrames-abs(TpLength), TpFrames)
    Tpclip= (TpLength>0) ? loop(trim(TpClip, TpFrames, TpFrames),abs(TPLength)) : TpClip
    Return TpClip
    }


    function TransPrepBack( clip TpClip, int TPLength)
    {
    TpFrames = TpClip.framecount()
    Tpclip= (TpLength>0) ? loop(trim(TpClip, TpFrames, TpFrames),abs(TPLength)) : TpClip
    TpClip= (TpFrames-abs(TpLength)<0) ? loop(trim(TpClip, 0, -1),(abs(TpLength+TpFrames)))+TpClip : trim (TpClip, 0, TpFrames)
    Return TpClip
    }


    #code by tsp - cf=current_frame,fr=framerate
    function convert2smpte(int cf,float fr)
    {
    hh=int(cf/3600/fr)
    mm=int((cf-hh*3600*fr)/60/fr)
    ss=int((cf-hh*3600*fr-mm*60*fr)/fr)
    ff=int((cf-hh*3600*fr-mm*60*fr-ss*fr))
    smpte=string(hh,"%02.0f")+":"+string(mm,"%02.0f")+ ":"+string(ss,"%02.0f")+"."+string(ff,"%02.0f" ) return smpte }
    function convert2hhmmscff(int cf,float fr)
    {
    hh=int(cf/3600/fr)
    mm=int((cf-hh*3600*fr)/60/fr)
    ss=int((cf-hh*3600*fr-mm*60*fr)/fr)
    ff=int((cf-hh*3600*fr-mm*60*fr-ss*fr))
    smpte=string(hh,"%02.0f")+":"+string(mm,"%02.0f")+ ":"+string(ss,"%02.0f")+"."+string(ff,"%02.0f" ) return smpte }

    function convert2srt(int cf,float fr)
    {
    hh=int(cf/3600/fr)
    mm=int((cf-hh*3600*fr)/60/fr)
    ss=int((cf-hh*3600*fr-mm*60*fr)/fr)
    fftemp=int(cf-hh*3600*fr-mm*60*fr-ss*fr)
    ff=((fftemp))
    smpte=string(hh,"%02.0f")+":"+string(mm,"%02.0f")+ ":"+string(ss,"%02.0f")+","+string(ff,"%03.0f" )
    return smpte
    }

    function Trim2(clip c, int start, int "end", int "length")
    {
    Assert(!(Defined(end) && Defined(length)),
    \ "Trim2: <end> and <length> parameters cannot be used together")
    Assert(!Defined(length) || length >= 0,
    \ "Trim2: invalid length: " + String(length))

    end = Defined(end)
    \ ? ((end < 0) ? (c.FrameCount() + end) : end)
    \ : Max(start, c.FrameCount())
    end = Defined(length) ? (start + length) : end

    Assert(start >= 0, "Trim2: start frame out of bounds: " + String(start))
    Assert(end >= start, "Trim2: end frame out of bounds: " + String(end))

    start = Min(start, c.FrameCount())
    end = Min(end, c.FrameCount())

    # we can't use Trim(start, end - 1) in case end == 1
    return (start == end)
    \ ? c.NullClip()
    \ : c.Trim(start, -(end - start))
    }

    function Trim3(clip c, int start, int "end", int "length")
    {
    Assert(!(Defined(end) && Defined(length)),
    \ "Trim3: <end> and <length> parameters cannot be used together")
    Assert(!Defined(length) || length > 0,
    \ "Trim3: invalid length: " + String(length))

    end = Defined(length) ? (start + length) : Default(end, c.FrameCount())
    end = (end < 0) ? (c.FrameCount() + end) : end

    Assert(start >= 0 && start < c.FrameCount(),
    \ "Trim3: start frame out of bounds: " + String(start))
    Assert(end > start && end <= c.FrameCount(),
    \ "Trim3: end frame out of bounds: " + String(end))

    return c.Trim2(start, end)
    }

    function Min(val a, val b) { return (a < b) ? a : b }

    function Max(val a, val b) { return (a > b) ? a : b }

    function Clamp(val n, val low, val high) { return Max(low, Min(n, high)) }

    # MaskTransition by stickboy
    function MaskTransition(clip c1, clip c2, imgpath , int dur)
    {
    c2=c2.Lanczos4Resize(c1.Width(),c1.Height())
    c1=c1.Lanczos4Resize(c2.Width(),c2.Height())
    ramp = imagesource(imgpath, 0, 0, 1, false).ConvertToRGB32()
    ramp = ramp.Lanczos4Resize(720,480)
    ramp = ramp.AssumeFPS(c1.FrameRate()).Loop(dur)
    transitionMask = Animate(ramp, 0, dur, "Levels",
    \ 0, 1.0, 20, 0, 235,
    \ 235, 1.0, 255, 0, 235)

    Assert( c1.Width() == c2.Width()
    \ && c1.Width() == transitionMask.Width()
    \ && c1.Height() == c2.Height()
    \ && c1.Height() == transitionMask.Height(),
    \ "JDL_MaskTransition: clips must have identical frame sizes")
    Assert( c1.FrameRate() == c2.FrameRate()
    \ && c1.FrameRate() == transitionMask.FrameRate(),
    \ "JDL_MaskTransition: clips must have identical frame-rates")

    overlap = transitionMask.FrameCount()
    Assert(overlap > 0, "JDL_MaskTransition: invalid overlap length: " + String(overlap))

    Assert(c1.FrameCount() >= overlap && c2.FrameCount() >= overlap,
    \ "JDL_MaskTransition: clips must be longer than the transition")

    trans1 = c1.Trim3(c1.FrameCount() - overlap)
    trans2 = c2.Trim3(0, length=overlap)
    Assert(trans1.FrameCount() == trans2.FrameCount(), "JDL_MaskTransition: bad math")
    trans = Overlay(trans2, trans1, mask=transitionMask)

    video = trans
    return video
    }

    function Min(val a, val b) { return (a < b) ? a : b }

    function Max(val a, val b) { return (a > b) ? a : b }

    function AddBack(clip imagef, clip imageb, int dur)
    {
    b = imageB.converttorgb32()
    f = imageF.Levels(0, 1, 255, 21, 255, coring=false).converttorgb32()
    fa = imageF.converttorgb32()
    x = (width(b)/2)-(width(f)/2)
    y = (height(b)/2)-(height(f)/2)
    c= overlay(b,f,x,y,mask=showalpha(fa), mode="blend")
    return c.converttoyv12()
    }

    function SafeSize(image, int SafeW, int SafeH, float fps)
    {
    a = image
    w= Width(a)
    h= Height(a)
    h = (w > SafeW) ? multifour(h * SafeW/float(w)) : h
    w = (w > SafeW) ? SafeW : w
    w = (h > SafeH) ? multifour(w * SafeH/float(h)) : w
    h = (h > SafeH) ? SafeH : h
    return ((Width(a) != w) || (Height(a) != h)) ? a.LanczosResize(multifour(w), multifour(h)) : a
    }

    function Has169(clip rescheck)
    {
    return rescheck
    }

    function HasAudio(clip chkaud)
    {
    return chkaud.AudioRate() != 0
    }

    function HasMono (clip mon)
    {
    return audiochannels(mon)!=2
    }

    function pointchk (inval, outval)
    {
    return inval>outval
    }

    function multifour (val mfour)
    {
    return (int(mfour/4))*4
    }

    function eqaudio(clip eqaud)
    {
    eqaud = eqaud.HasAudio() ? eqaud : audiodub(eqaud,BlankClip(eqaud.framecount, fps = 29.970, audio_rate=48000))
    eqaud = HasMono(eqaud) ? MergeChannels(eqaud.GetChannel(1), eqaud.GetChannel(1)) : eqaud
    return eqaud.ResampleAudio(48000)
    }

    function AddAlphaBack(clip imagef, clip imageb)
    {
    b = imageB
    f = imageF.Levels(0, 1, 255, 1, 255, coring=false)
    x = (width(b)/2)-(width(f)/2)
    y = (height(b)/2)-(height(f)/2)
    c = Layer(b,f,"add",255,x,y)#,0,use_chroma=true)
    return c
    }
    function AddAlphaBackNoLev(clip imagef, clip imageb)
    {
    b = imageB
    f = imageF#.Levels(0, 1, 255, 21, 255, coring=false)
    x = (width(b)/2)-(width(f)/2)
    y = (height(b)/2)-(height(f)/2)
    c = Layer(b,f,"add",255,x,y)#,0,use_chroma=true)
    return c
    }

    function SafeSizeKB(image, int SafeW, int SafeH)
    {
    a = image
    w= Width(a)
    h= Height(a)
    h = (w > SafeW) ? multifour(h * SafeW/float(w)) : h
    w = (w > SafeW) ? SafeW : w
    w = (h > SafeH) ? multifour(w * SafeH/float(h)) : w
    h = (h > SafeH) ? SafeH : h
    return ((Width(a) != w) || (Height(a) != h)) ? a.LanczosResize(multifour(w), multifour(h)) : a
    }

    function importavs(string impavs)
    {
    import(impavs).AssumeFPS(29.970, true).eqaudio()
    }

    ResampleAudio(48000)
    ChangeFPS(29.970)
    textsub("C:\Program Files\DVD slideshow GUI\DVDsGUItemp.ssa")
    Quote Quote  
  24. I haven't analyzed the entire script. There are a lot of Levels() and ConvertTo...() where the problem could be happening. But try changing the part that reads:

    Code:
    Try {
    imgout=ImageSource("C:\Temp Video\black white black slide 9_temp_files\black white black slide 9%06d.ebmp", 0,3, rate)
    }
    To:

    Code:
    Try {
    imgout=ImageSource("C:\Temp Video\black white black slide 9_temp_files\black white black slide 9%06d.ebmp", 0,3, rate).converttoyv12(matrix="PC.601")
    }
    Ie, add ".converttoyv12(matrix="PC.601")" to the end of the long line.
    Quote Quote  
  25. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    I added ".converttoyv12(matrix="PC.601")". It made the black slide black, but it also made the white slide black.

    Also tried ".converttoYUY2(matrix="PC.601")", both slides were still black.

    Also tried ".converttoyv12" and ".converttoYUY2". Both of these looked like the original & displayed a dark gray slide.
    Quote Quote  
  26. You mean the image with the white patch came out completely black?
    Quote Quote  
  27. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    Originally Posted by jagabo
    You mean the image with the white patch came out completely black?
    Yes, the white image was completely black. I cut/past the additional script to make sure there would be no mistake. I tried this a few times to make sure. I also changed the script on another .avs file of 18 slides and they all displayed black.

    As I looked at the following line, I noticed something.

    imgout=ImageSource("C:\Temp Video\black white black slide 9_temp_files\black white black slide 9%06d.ebmp", 0,3, rate)

    My slideshow .avs file is "C:\Temp Video\black white black slide 9.avs“.

    But the program created a folder for the temp files, “\black white black slide 9_temp_files”. There are 4 files, all with the extension of .ebmp and all are 507 KB in size. I’m guessing the background image plus the 3 slide images.

    I searched on “ebmp” and found this.
    http://avisynth.org/ImageSource

    I looked at temp files for other .avs slideshows & they follow the same format. If the program is loading images saved in the temp file, could their colors already be converted before saving?

    If I burn a DVD-R directly from the slideshow, no temp file is created, at least not one that I ever saw.
    Quote Quote  
  28. Originally Posted by Mike99
    I searched on “ebmp” and found this.
    http://avisynth.org/ImageSource

    I looked at temp files for other .avs slideshows & they follow the same format. If the program is loading images saved in the temp file, could their colors already be converted before saving?
    ImageWriter() produces .ebmp files with the colorspace of the source. If it's RGB you can rename the file .bmp and any paint program should be able to open it. YUY2 and YV12 are more difficult. It's possible the contrast has already been changed in the ebmp files. Try looking at one.

    I may download the slideshow program and take a look myself...

    <edit>

    I downloaded the program and found that the ebmp files are in YV12. The black level (Y) is set at 30, and the white level at 235. In the AVS script that I exported the very last line was "Levels(32, 1, 235, 16, 235, coring=false)". This restores the black to the approximately correct level, Y=16. I don't know why the program bumps the black level up only to bring it back down again later (losing a little precision in the process). In the end, the AVS script and an exported MPG file had correct black levels in the picture data.

    The background was handled differently though. During the script the black and white levels appear to be correct, 16-235. But that final Levels() command brings the black level down to 0, crushing blacks within the background image.

    I don't know why your script was missing the final Levels() command. Maybe there is an option somewhere within the program that controls this?

    </edit>
    Quote Quote  
  29. Member
    Join Date
    Jan 2006
    Location
    United States
    Search Comp PM
    I had several .avs files and none of them had the “Levels” last line. I was using program version 09.07. I wondered if something had changed, went to the program web site and there is version 09.08 dated today, Nov 11, 2008.

    I d/l the new version and guess what - a saved .avs file now has the “Levels” line. It appears that you got the new version right after it came out.

    You mentioned “The background was handled differently though. During the script the black and white levels appear to be correct, 16-235. But that final Levels() command brings the black level down to 0, crushing blacks within the background image.”

    When I added the “ConvertToYUY2()” and “VideoScope("bottom", true, "Y", "Y", "Y")” lines to the end of the new script, it looked like the black background was luma 16. I did not see it going down to 0. Is the “ConvertToYUY2()” changing it back up to 16? Or am I misinterpreting the something?
    Quote Quote  
  30. Originally Posted by Mike99
    I had several .avs files and none of them had the “Levels” last line. I was using program version 09.07. I wondered if something had changed, went to the program web site and there is version 09.08 dated today, Nov 11, 2008.

    I d/l the new version and guess what - a saved .avs file now has the “Levels” line. It appears that you got the new version right after it came out.
    Yes, I downloaded the file this morning so I got the latest release.

    Originally Posted by Mike99
    You mentioned “The background was handled differently though. During the script the black and white levels appear to be correct, 16-235. But that final Levels() command brings the black level down to 0, crushing blacks within the background image.”

    When I added the “ConvertToYUY2()” and “VideoScope("bottom", true, "Y", "Y", "Y")” lines to the end of the new script, it looked like the black background was luma 16. I did not see it going down to 0. Is the “ConvertToYUY2()” changing it back up to 16? Or am I misinterpreting the something?
    If you just want a black background there is no problem. The problem is that blacks below RGB 16 in a background image all get crushed luma 16:



    (That image was converted from YV12 to RGB without the usual contrast expansion so black should be at 16, white at 235. But remember the numbers printed in the images are the intensities of the original RGB source.) Notice how you can differentiate the 0 and 16 patches in the the inner image, but the 0 and 16 patches in the background image are both same intensity. So dark details in the background image would be lost.

    I think the added Levels() command in the latest release was a quick and dirty fix for the main image and they didn't realize they were screwing up the background image.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!