Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 3rd February 2018, 16:32   #1  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 733
VideoTek (Avisynth Videoscope) v1.1

Hi,
I love the Tektronix Videoscope I have at work, but I can't use it at home, that's why I tried to reproduce a similar output using Avisynth built-in videoscope (Histogram).
I wrote it in like 5min, so feel free to modify it and make it better/faster/more complex.
Right now it doesn't have any parameters and you can call it like:

VideoTek()

Image: Link

picture (top left), luma (top right)
chroma (bottom left), audio channels and Lissajou (bottom right)

Changelog:

v0.7 crappy original version by FranceBB
v0.8 commit by magiblot
v0.9 major code cleanup by StainlessS
v1.0 added 6ch display with the graph of the first two by Stainless
v1.1 fixed a bug occurring with 1ch in the Lissajou graph by Stainless

Code:
#simple Videoscope by FranceBB
#special thanks to both magiblot and StainlessS
#it resembles Tektronix WVR 7020
#Accepts 8bit clip only. It works internally in 4:2:0 (yv12)
#Accepts up to 8 audio channels

Function VideoTek(clip clp) {
    clp
    nChannels=(HasAudio)?AudioChannels:0                        # ssS, HasAudio = audio_samples_per_second!=0
    Assert(IsYV12,"VideoTek: source must be yv12 (YUV 4:2:0 8bit)")
    Assert(nChannels<9,"VideoTek: sources with more than 8 audio channels are not supported")
    CSZ = 480                 # Chroma Size box (W & H)
    A_W = 320                 # Audio Box Width
    A_H = 460                 # Audio Box Height (Audio & Lissajoua)
    L_W = (704+704+6)-700-A_W # Lissajous Width
    SilentStereo=Last.BlankClip(width=1480, height=920,audio_rate=48000,channels=2,sample_type="Float")
    myBlack= (nChannels>0)  ? SilentStereo.AudioDubEx(Last) : SilentStereo.Killaudio
    Stereo = (nChannels>=2) ? Last.GetChannels(1,2) : (nChannels==1) ? MergeChannels(GetChannels(1),GetChannels(1)) : SilentStereo
    StereoClip = Last.BlankClip(width=16,height=16).AudioDub(Stereo)  # Histogram(mode="StereoOverlay") requires 2 channel only clip.
    Picture   = BicubicResize(704, 396)
    luma      = TurnRight.Histogram(mode="classic").TurnLeft.Crop(0,0,0,256).BiCubicResize(704, 396)
    chroma    = Histogram("color2").Crop(clp.Width, 0, 0,256).BilinearResize(CSZ,CSZ)
    Audio     = myBlack.Crop(0,0,A_W,A_H).Histogram(Mode="audiolevels")
    lissajous = StereoClip.Histogram(mode="StereoOverlay").BicubicResize(L_W,A_H)
    MyBlack
    Overlay(Picture,   x=0,                   y=0)
    Overlay(luma,      x=704+6,               y=0)
    Overlay(chroma,    x=(704-chroma.Width)/2,y=396 + (920-396-chroma.height)/2)
    Overlay(Audio,     x=704-4,               y=396 + (920-396-audio.height) /2)
    Overlay(lissajous, x=700+Audio.Width,     y=396 + (920-396-lissajous.height)  /2)
    return Last
}
Cheers.

Last edited by FranceBB; 23rd July 2018 at 14:07.
FranceBB is offline   Reply With Quote
Old 3rd February 2018, 23:25   #2  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,184
To me the real deal of Tektronix's hardware is the double diamond vectorscope, it makes color matching looks so easy. But I think they patented it.
https://www.youtube.com/watch?v=8NTLqybQQSU
lansing is offline   Reply With Quote
Old 4th February 2018, 16:12   #3  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 733
@lansing... yep, that's really useful, but I mainly work on post-production, so this is how I set it:

Tektronix - Avisynth

Another example: https://i.imgur.com/EF3VWbu.png
FranceBB is offline   Reply With Quote
Old 6th February 2018, 20:50   #4  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,184
Taking more look into the screenshot, the proportion of the graphs should be independent from the video window, they shouldn't be scaled 16:9 along with the video. And there needs to be boxes in the vectorscope to indicate the legal saturation range for standard definition and high definition. Also the wave form needs to have a some kind of indication of brightness, such as percentage.

I have a video only clip and it just return an error because I don't have an audio.

Last edited by lansing; 6th February 2018 at 20:57.
lansing is offline   Reply With Quote
Old 21st July 2018, 12:07   #5  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 733
I updated it to a newer version. It's supposed to automatically detect the audio channels number and make a graph accordingly, but... it doesn't work... I think I broke my own code xD

Do you have any idea why it doesn't show the audio graph anymore?
__________________
Broadcast Encoder
Avisynth memes: 1 - 2 - 3
Videotek - Audacity XP - LUT Collection
FranceBB is offline   Reply With Quote
Old 21st July 2018, 12:36   #6  |  Link
magiblot
Eurobeat Fan
 
Join Date: Sep 2014
Posts: 97
Well, you store things into the my_audio_levels_overlayX variables and then leave them unused.
magiblot is offline   Reply With Quote
Old 21st July 2018, 13:06   #7  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 733
That's the thing. I'd like to use Overlay(audio_levelsx) according to how many channels are detected, but I don't know how to do it.
__________________
Broadcast Encoder
Avisynth memes: 1 - 2 - 3
Videotek - Audacity XP - LUT Collection

Last edited by FranceBB; 21st July 2018 at 13:33.
FranceBB is offline   Reply With Quote
Old 21st July 2018, 14:41   #8  |  Link
magiblot
Eurobeat Fan
 
Join Date: Sep 2014
Posts: 97
No problem

Try with the following changes:

Code:
source_audio_channels = clp.AudioChannels() #Does this return 0 if there is no audio?

myaudio = (source_audio_channels==0) ? GetChannels(myfakeaudio, 1, 2) :
\ (source_audio_channels==1) ? GetChannels(clean, 1) :
\ (source_audio_channels==2) ? GetChannels(clean, 1, 2) :
\ (source_audio_channels==3) ? GetChannels(clean, 1, 2, 3) :
\ (source_audio_channels==4) ? GetChannels(clean, 1, 2, 3, 4) :
\ (source_audio_channels==5) ? GetChannels(clean, 1, 2, 3, 4, 5) :
\ (source_audio_channels==6) ? GetChannels(clean, 1, 2, 3, 4, 5, 6) :
\ (source_audio_channels==7) ? GetChannels(clean, 1, 2, 3, 4, 5, 6, 7) :
\ (source_audio_channels==8) ? GetChannels(clean, 1, 2, 3, 4, 5, 6, 7, 8) :
\ NOP()

for_audio_levels = AudioDub(myblack, myaudio)

audio_levels = for_audio_levels.Histogram("audiolevels").Crop(0, 0, -736, -0).BilinearResize(340, 420)

my_audio_levels_overlay = Overlay(audio_levels, x=700, y=450, opacity=1.0, mode="blend", greymask=true, ignore_conditional=false, pc_range=false)


final=Overlay(my_audio_levels_overlay) #you will probably want to add additional parameters
There could be syntax errors, I edited this from mobile.
magiblot is offline   Reply With Quote
Old 21st July 2018, 15:10   #9  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,478
Where is 'mylissajou' supposed to come from ? (what histogram or whatever plug).

EDIT: Histogram(mode="StereoOverlay") ???
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 21st July 2018 at 15:13.
StainlessS is offline   Reply With Quote
Old 21st July 2018, 16:02   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,478
Looks about right, might need [EDIT: WILL NEED] some adjustment to dimension, overlay coords.
Have used Histogram(mode="StereoOverlay") for the mylissajou thing, hope that its correct.

Code:
#simple Videoscope by FranceBB:- https://forum.doom9.org/showthread.php?t=175249
#it resembles Tektronix WVR 7020
#Accepts 8bit clip only. It works internally in 4:2:0 (yv12)
#Accepts up to 8 audio channels

Function VideoTek(clip clp) {
    clp
    nChannels=(HasAudio)?AudioChannels:0                        # ssS, HasAudio = audio_samples_per_second!=0
    #Assert block
    Assert(IsYV12,"VideoTek: source must be yv12 (YUV 4:2:0 8bit)")
#   Assert(IsFrameBased, "VideoTek: source must be progressive") # ssS, IsFrameBased means SeparateFields NOT used, does not indicate Progressive
    Assert(nChannels<9,"VideoTek: sources with more than 8 audio channels are not supported")

    SilentStereo=Last.BlankClip(width=1480, height=920,audio_rate=48000,channels=2,sample_type="Float")
    myBlack= (nChannels>0)  ? SilentStereo.AudioDubEx(Last) : SilentStereo.Killaudio
    Stereo = (nChannels>=2) ? Last.GetChannels(1,2) : (nChannels==1) ? MergeChannels(GetChannels(1),GetChannels(1)) : SilentStereo
    StereoClip = Last.BlankClip(width=460,height=460).AudioDub(Stereo)  # Histogram(mode="StereoOverlay") requires 2 channel only clip.

    clean1=PointResize(704, 396)
    Picture    = clean1
    luma       = clean1.TurnRight.Histogram(mode="classic").TurnLeft.Crop(0,0,0,256).BilinearResize(704, 396)
    chroma     = clean1.Histogram("color2").Crop(704, 0, 256,256).BilinearResize(480,480)
    Audio      = myBlack.Crop(0,0,340,420).Histogram(Mode="audiolevels")
    mylissajou = StereoClip.Histogram(mode="StereoOverlay")  # Dont know where to get lissajou from, so improvised

    Result = MyBlack
    Result = Result.Overlay(Picture,    x=0, y=0)        # ssS, Removed all of the Optional Args assigned with Defaults
    Result = Result.Overlay(luma,       x=710, y=0)
    Result = Result.Overlay(chroma,     x=100, y=430)
    Result = Result.Overlay(Audio,      x=700, y=450)
    Result = Result.Overlay(mylissajou, x=1000,y=450)
    return Result
}
EDIT: BugFixed : EDIT: Same bug fixed AGAIN !!!

Untested with more than 2 channels. [EDIT: or with single channel, tested on 0 and 2 channels only]

Code:
ColorBars(Pixel_Type="YV12")
VideoTek
Return Last.Spline64Resize(854,480)


EDIT: Below bottom right image is more like what I remember as lissajou figure [EDIT: perhaps samplerate just too low]


EDIT:
Quote:
Stereo = (nChannels>=2) ? Last.GetChannels(1,2) : SilentStereo
Not sure how to process/mix multiple channels into stereo, above, just selected Left and Right.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 22nd July 2018 at 00:35.
StainlessS is offline   Reply With Quote
Old 21st July 2018, 18:55   #11  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 733
Thank you magiblot and StainlessS

@StainlessS... yes, it's Histogram(mode="StereoOverlay"). The idea is to pick both Left and Right channel when stereo and pick just Front Left and Front Right when is Dolby.

It might not be as complex and detailed as the official waveform provided by Tektronix, but it kinda reminds its layout and it uses the internal filters already available in Avisynth, so I thought it was kinda cool to have a similar layout. ^_^

Thank you both, once again, this is exactly what I wanted. ^_^
__________________
Broadcast Encoder
Avisynth memes: 1 - 2 - 3
Videotek - Audacity XP - LUT Collection
FranceBB is offline   Reply With Quote
Old 21st July 2018, 19:32   #12  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,478
bugFix,

was
Code:
    Stereo = (nChannels>=2) ? Last.GetChannels(1,2) : (nChannels==2) ? MergeChannels(GetChannels(1),GetChannels(1)) : SilentStereo
should have been
Code:
    Stereo = (nChannels>=2) ? Last.GetChannels(1,2) : (nChannels==1) ? MergeChannels(GetChannels(1),GetChannels(1)) : SilentStereo
I'll leave it to you to perfect it.
Fixed in prev post.

EDIT: Your original Big Buck Bunny Link (downsized to 854,480)


And current script(approx same frame, needs some coords fixed a bit)



EDIT:
Quote:
The idea is to pick both Left and Right channel when stereo and pick just Front Left and Front Right when is Dolby.
From Avs Docs
Quote:
Every file format has a different internal channel ordering. The following table gives this internal ordering for some formats (useful for plugin writers), but it is a decoder task supply to AviSynth the expected channel order (like WAV), if you use decoders like NicAudio/BassAudio or ffdshow/AC3_filter you don't need to worry about this:
Code:
reference:      channel 1:     channel 2:     channel 3:     channel 4:     channel 5:     channel 6:
5.1 WAV         front left     front right    front center      LFE         rear left      rear right
So I take it that channels 1 and 2 should be correct whether DOLBY or not (as we are dealing with WAV order).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 21st July 2018 at 21:18.
StainlessS is offline   Reply With Quote
Old 21st July 2018, 23:12   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,478
Bit more fiddling about.
Code:
Function VideoTek(clip clp) {
    clp
    nChannels=(HasAudio)?AudioChannels:0                        # ssS, HasAudio = audio_samples_per_second!=0
    Assert(IsYV12,"VideoTek: source must be yv12 (YUV 4:2:0 8bit)")
    Assert(nChannels<9,"VideoTek: sources with more than 8 audio channels are not supported")
    CSZ = 480                 # Chroma Size box (W & H)
    A_W = 320                 # Audio Box Width
    A_H = 460                 # Audio Box Height (Audio & Lissajoua)
    L_W = (704+704+6)-700-A_W # Lissajous Width
    SilentStereo=Last.BlankClip(width=1480, height=920,audio_rate=48000,channels=2,sample_type="Float")
    myBlack= (nChannels>0)  ? SilentStereo.AudioDubEx(Last) : SilentStereo.Killaudio
    Stereo = (nChannels>=2) ? Last.GetChannels(1,2) : (nChannels==1) ? MergeChannels(GetChannels(1),GetChannels(1)) : SilentStereo
    StereoClip = Last.BlankClip(width=16,height=16).AudioDub(Stereo)  # Histogram(mode="StereoOverlay") requires 2 channel only clip.
    Picture   = BicubicResize(704, 396)
    luma      = TurnRight.Histogram(mode="classic").TurnLeft.Crop(0,0,0,256).BiCubicResize(704, 396)
    chroma    = Histogram("color2").Crop(clp.Width, 0, 0,256).BilinearResize(CSZ,CSZ)
    Audio     = myBlack.Crop(0,0,A_W,A_H).Histogram(Mode="audiolevels")
    lissajous = StereoClip.Histogram(mode="StereoOverlay").BicubicResize(L_W,A_H)
    MyBlack
    Overlay(Picture,   x=0,                   y=0)
    Overlay(luma,      x=704+6,               y=0)
    Overlay(chroma,    x=(704-chroma.Width)/2,y=396 + (920-396-chroma.height)/2)
    Overlay(Audio,     x=704-4,               y=396 + (920-396-audio.height) /2)
    Overlay(lissajous, x=700+Audio.Width,     y=396 + (920-396-lissajous.height)  /2)
    return Last
}
Can mess with this lot to auto center stuff, when happy then might want to hard code numbers.
Code:
    CSZ = 480                 # Chroma Size box (W & H)
    A_W = 320                 # Audio Box Width
    A_H = 460                 # Audio Box Height (Audio & Lissajoua)
    L_W = (704+704+6)-700-A_W # Lissajous Width
Have also converted from PointResized source to input source for histogram stuff, and used Bicubic instead where resize necessary,
if too slow, then change BiCubics to BiLinear.

EDIT: Added Levels() on Lissajous trying to make more visible, only minor improvement (before downsize).

Here, downsized,


EDIT:
In Steinberg, I think that the Lissajous thing is known as Phase (or Phase Scope), when spreads out horizontally, is broader stereo,
if dot or vertical line, then is mono, height being amplitude (I guess FranceBB, already knows this).
The Phase Scope, shows info from only first two channels (Left & Right, it is stereo specific, perhaps eg 5.1 should be downmixed somehow).

EDIT: Moved Levels() before BiCubicResize() for Lissajous.
(Levels improvement is only on the cross hair thing, is a bit more visible on FranceBB linked image than in this script)

EDIT:
Changed Levels 126-4 and 126+4, to 126-1, 126+1. (126 being TV levels mid point)
Code:
lissajous = StereoClip.Histogram(mode="StereoOverlay").Levels(126-1,1.0,126+1,16,235,coring=false).BicubicResize(L_W,A_H)
EDIT: Damn, below bug crept back in again, fixed in blue [was (nChannels==2)].
Code:
Stereo = (nChannels>=2) ? Last.GetChannels(1,2) : (nChannels==1) ? MergeChannels(GetChannels(1),GetChannels(1)) : SilentStereo
EDIT: Levels() removed from Lissajous thing, it emphasized the cross hairs stuff, but messed with the dust cloud a bit.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 22nd July 2018 at 01:24.
StainlessS is offline   Reply With Quote
Old 23rd July 2018, 09:23   #14  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,478
FrancBB, I see your there,
NOTE, the bug that crept back in is also present in your 1st post, must have edited on-line and forgot to make same bug fix in my script
and then made mod with unfixed script.
(2nd last edit in above post).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 23rd July 2018, 11:38   #15  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 733
Quote:
when spreads out horizontally, is broader stereo,
if dot or vertical line, then is mono, height being amplitude (I guess FranceBB, already knows this).
Yes, I use it on a daily basis at work to check whether there's difference between channels in a stereo pair or not.

Quote:
NOTE, the bug that crept back in is also present in your 1st post
Oh, I see...

Quote:
So I take it that channels 1 and 2 should be correct whether DOLBY or not (as we are dealing with WAV order).
Yes, it's always gonna follow the wav order 'cause Avisynth internally works with this order, so, if someone indexes a video file that has an AC3 Dolby audio track with an indexer, it's up to the indexer to return a WAV audio order to Avisynth.



Anyway, thank you for modifying the code. I owe you a beer.
Perhaps, one day, when there'll be perfect 3D scanners... xD
__________________
Broadcast Encoder
Avisynth memes: 1 - 2 - 3
Videotek - Audacity XP - LUT Collection
FranceBB is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:51.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.