Log in

View Full Version : waveform - audio waveform display


Pages : [1] 2

wonkey_monkey
19th August 2012, 20:57
This filter is now deprecated in favour of version 2.0 (https://forum.doom9.org/showthread.php?t=182866)

Inspired by audiograph (http://avisynth.org.ru/docs/english/externalfilters/audiograph.htm), waveform is a plugin to overlay audio waveforms on video clips - useful for identifying sync issues and audio glitches.

Download: waveform0.3.zip (http://horman.net/avisynth/download/waveform0.3.zip)

http://horman.net/waveform.png

(these screenshots are now out of date; see post further down)

No prizes for guessing what my favourite TV show is...

Improvements over audiograph are:


A nicer, variable height overlay
Separate graphs for each channel, works with an arbitrary number of channels
Works with YV12 video, as well as YUY2/RGB24/RGB32
Audio format is passed through unchanged


waveform
========

An Avisynth plugin to display audio waveforms superimposed on video clips.

Usage
=====

waveform(clip, int "window", float "height", bool "under", float "zoom", bool "marks")

Parameters:
-----------

window: the number of frames either side to display a waveform for (default: 1)
height: >=1 : height in pixels of each audio channel displayed
<1 : total height of waveform display as a fraction of video height (default: 0.333)
under: if true, display the waveform underneath the video instead of superimposed on it (default: false)
zoom: scale up the waveform (default: 1)
marks: display frame boundary marks (default: true)

Wilbert
19th August 2012, 21:30
Nice! It would me even more nicer if you make it open source. Is there a reason you keep your plugins closed source?

wonkey_monkey
19th August 2012, 21:53
Only embarrassment over my lazy coding ;)

(download updated to include source)

RedDwarf1
20th August 2012, 00:44
Thanks, I will give it a try.

You must be looking forward to the new series very soon ;)

StainlessS
20th August 2012, 01:07
Lovely, Thank you. :thanks:

wonkey_monkey
21st August 2012, 22:54
You must be looking forward to the new series very soon ;)

New series?! :eek: ;)

I've made a couple of tweaks to the filter - a new parameter, zoom, magnifies the waveform vertically without amplifying the clip's audio (this may result in what looks like clipping, but isn't), and past/future frames are now darker than the current frame (this is because I spent half-an-hour wondering why my clip contained a glitch I thought I had trimmed out, when actually my VirtualDub window was cropped and I wasn't looking at the right section of the waveform... :o)

The filter will also now overlay the clip with "waveform: no audio" if there is, fittingly, no audio.

http://horman.net/waveform2.png

David

StainlessS
21st August 2012, 23:46
Very nice work, love the zoom option, 1st usage v0, thought it was not working because of the
nearly flat line audio, it was just quiet. Much better that AudioGraph.
Was on my list of things to do, clean up AudioGraph, not gonna bother now.
Good stuff, thanks very much.

EDIT: PS, request future version numbers on Zip file.

pandy
28th August 2012, 12:10
Nice one, very useful - Thank You!

StainlessS
31st August 2012, 12:22
David, finally had a little play with it (second version), dont work I'm afraid.

Waveform(window=1,height=0.333,under=false,zoom=1.0) # Set to stated defaults, nothing happens (YV12/YUY2/RGB32
Waveform(window=0,height=0.0,under=false,zoom=1.0) # Set to actual defaults, nothing happens (YV12/YUY2/RGB32
Waveform(window=2,height=0.333,under=true,zoom=1.0) # Green screen (YV12/YUY2/RGB32
Waveform(window=1,height=0.333,under=true,zoom=1.0) # YV12 green screen
Waveform(window=1,height=0.333,under=true,zoom=1.0) # YUY2 green bottom screen
Waveform(window=1,height=0.333,under=true,zoom=1.0) # RGB32 green bottom screen
Waveform(window=1,height=60.0,under=true,zoom=1.0) # YV12 Multicolored Greens

At no time saw any audio graph.

Old version worked fine.

Also, cpp file is not for current dll, it does not compile due to vsprintf_s, needs additional header
and 1 too few args. EDIT: Suggest change vsprintf_s to vsprint, then debug() should work OK I think.

Also some kind of planar misalignment in YV12, and dont like use of memcpy/memset.
Pitch can be greater than Rowsize, and start of row not necessarily aligned at offset 0 WRT pitch,
if you splat the last raster line with memset at size pitch, it can wrap around and mash up memory that does not
belong to the last scanline, offset 0 + pitch is start of next row but the could be mem beween there and end of last row (eg crop).
Did not look any further into code, looks well compilcated.

Keep at, ;)

PS, I was wanting to test the version preroll that I did, as you did not even acknowledge its existence, I guessed
it was of no interest to you and so did not bother any further with it. It has been tested in sofar as it dont crash,
but I did not try to find any dodgy audio to fix.
By the way, typical request for samples is 6000, not 60,000 as I mis-remembered in preroll thread, maybe
about 1/8 second with 48khz audio.

wonkey_monkey
31st August 2012, 18:34
David, finally had a little play with it (second version), dont work I'm afraid.

At no time saw any audio graph.

Old version worked fine.

Currently working through your suggested fixes (not sure what I did wrong but the uploaded dll is definitely broken), but I've discovered a crash I can't narrow down - something to do with GetAudio, but it only seems to arise when the video is small (like version is), and happens even if I bypass all the drawing code entirely. :confused:

David

wonkey_monkey
31st August 2012, 19:07
Okay, I give up on the crash for now - for all I know right now, it could be some bizarre bug in tone itself (replace tone with a wavsource of tone and the crash is gone).

Anyway, better that there is at least a somewhat-working version (no idea what I did to that last dll) for people to use...

Download: waveform0.2.zip (http://horman.net/waveform0.2.zip)

I commented out the function which uses vsprintf_s and hopefully fixed those rowsize/pitch issues (but only for YV12/YUY2 so far).

Still not sure what you meant about the YV12 misalignment?

David

Wilbert
31st August 2012, 20:52
Currently working through your suggested fixes (not sure what I did wrong but the uploaded dll is definitely broken), but I've discovered a crash I can't narrow down - something to do with GetAudio, but it only seems to arise when the video is small (like version is), and happens even if I bypass all the drawing code entirely.
Could you post the script which crashes?

StainlessS
31st August 2012, 21:48
I think this one, caused the suspected planar misalignment,mostly greenish, with a sort of yellow separate image with offset (I think).
Waveform(window=1,height=60.0,under=true,zoom=1.0) # YV12 Multicolored Greens

I think if you re-establish the debug() func as suggested, it should work OK and be of use in debugging, so can use sprintf type syntax.
The _s version is I think an MS "Safe" version which prevents buffer overflow, as buf is 1024, you are unlikely to overflow it unless
deliberate. The _s version, just has an extra arg for the buffer size (which is missing in your source) so it looks like a failed attempt
to use the _s version.
There is a thread/s somewhere, about AudioGraph, the cache bug in 2.58, and if I remember correctly; about it being not quite thread
safe to pull in audio from a video GetFrame. Think IanB and Wilbert participated in those threads.

Oh, and about the memset stuff, could I think use something like "n * pitch - (Pitch-Rowsize)" which should account for the wrap around.

wonkey_monkey
31st August 2012, 22:55
Could you post the script which crashes?

Sure, it was simply this:


version.audiodub(tone).waveform(1).info


It would crash, usually, at 66, and using DebugView it didn't seem to be getting further than my GetAudio.

Inserting a "getchannel(1)" before the the waveform(1) stopped it crashing. Swapping "version" for "stackvertical(version,version)" moved the crash point to around frame 34. Changing to "version.bicubicresize(720,576)" would result in no crashes.

I should point out I'm currently back on AviSynth 2.58, since the only reason I moved to 2.6 was to try to solve my preroll problem, which I have a filter for now (and a new version of NicAudio), so...

There is a thread/s somewhere, about AudioGraph, the cash bug in 2.58, and if I remember correctly; about it being not quite thread
safe to pull in audio from a video GetFrame. Think IanB and Wilbert participated in those threads.

...this may be the reason.

David

wonkey_monkey
31st August 2012, 23:03
Oh, and about the memset stuff, could I think use something like "n * pitch - (Pitch-Rowsize)" which should account for the wrap around.

I'm very tired tonight and I've just realised I managed to screw up the rowsize stuff earlier. I've reuploaded the zip file, again :o I think it should be right now (and now includes your suggestion, thanks!).

David

Gavino
7th September 2012, 09:32
There is a thread/s somewhere, about AudioGraph, the cache bug in 2.58, and if I remember correctly; about it being not quite thread
safe to pull in audio from a video GetFrame.
You're probably thinking about this post.

As IanB says, the problem should be fixed for Avisynth clients that use the VfW interface, but some use the API directly instead.

lisztfr9
26th November 2012, 14:59
Hi,

These plugins are nice but i tried to use it for adjusting subtitle delay, maybe they are not suitable for that....?

L

Sparktank
26th November 2012, 16:06
Thank you so much for this!
Not only practical in serving a useful purpose, but looks quite fun as well ^__^

I am going to have so much fun with this.

-----

I don't know how difficult requests can get; but is there any way to add a color spectrum to the wave, based on volume level (dB)?

-----

This is actually quite interesting to use.
I'm using "AVS 2.6.0 Alpha 3 [110525]" with SEt's "Avisynth 2.6 MT 2012.08.28". (Though I haven't implemented any SetMT functions in the script, yet.)

I was having issues at first trying to get a working script.
At first, I got the video to load without problems in VirtualDub,and added in the AudioDub(v,a) at the end.
But it was telling me the waveform was an unsupported colorspace.
Which was extremely odd.
I tinkered with the script and finally looked at your short script and clued in to get it working.

The script finally worked for me and I was able to get VD running without errors.

Then I decided to try with the waveform underneath the video and do some cropping.
This took some math and trial and errors to get the aspect ratio correct, but I finally got it (I think).

For fun, I've taken up a new project.
I plan to take my Bluray of Big Trouble In Little China and convert it to DVD with the black bars cropped, proper aspect ratio kept, waveform added (waveform will calculated to replace black bars) for the isolated score (one of the special features), and use the main audio for playback.
The isolated score won't be playing during the video, I've loaded the main movie audio in VD separately while the isolated score is in the AVS script.
It should really make for a fun watching experience to "see" the music play throughout the movie.



A Question About Zoom:
Is there a maximum you can input?
I've tried anywhere from 0.5 to 90.5 and haven't really seen a difference. Am using it wrong?



I converted the audio to w64 using eac3to and used NicAudio 2.06 to import.

Here's a screencap of current results (MPC overriding AR to 16:9)
http://i46.tinypic.com/2vwiwqu.png

Here's the script I used...
Video = DirectShowSource("L:\1080p (Remux)\Big Trouble In Little China\Big Trouble In Little China.mkv", fps=23.976, audio=false)
Video = video.crop(0,134,-2,-134)
Video = video.spline144resize(720, 304)
Audio = RaWavSource("L:\1080p (Remux)\Big Trouble In Little China\Big Trouble In Little China.w64", SampleRate=48000, SampleBits=24, Channels=6)

AudioDub(video,audio).Waveform(1, .366, true, 1).LanczosResize(720,480)
### Override AR to 16:9 in media player for preview and to convert to DVD in AVStoDVD/HCenc

I haven't slept yet. I may have done something wrong in that script. :scared:

Reel.Deel
28th February 2015, 15:31
@davidhorman

I'm having some issues with waveform. I'm using the following script in AviSynth RC 1 MT (OS: 64-bit Windows 7).

audio = last #16-bit stereo in my case

fps = 30000
den = 1001
length = Round((AudioDuration(audio)*fps)/den)
BlankClip(length, width=1920, height=512, fps=fps, fps_denominator=den, pixel_type="YV12", color_yuv=$008080)
AudioDub(last, audio)
waveform(window=45, height=height/2, under=false, zoom=2.0)
With window=45 I get this error message:
Avisynth: access violation at 0x0000281A in waveform.dll, attempting to write to 0x061AFC60

With window=50 VDub just freezes but with window=240 it works. :confused:

Also I was wondering if you can add a few options to waveform.
1) Option to select the background color. I thought waveform would work something like Histogram("AudioLevels") when used with BlankClip but I cannot get the desired color after waveform.
2) Option to only display the the pure waveform without the the window marks (center ones are fine, is just when the window is set high the marks are very close together and become a little intrusive).
3) Can anything be done to make waveform scroll a bit more smoothly?

wonkey_monkey
28th February 2015, 16:47
Try this, which I think fixes the crash:

http://horman.net/avisynth/download/waveform0.3.zip

New parameter "marks" can be set to false remove the vertical lines.

1) Option to select the background color. I thought waveform would work something like Histogram("AudioLevels") when used with BlankClip but I cannot get the desired color after waveform.

That histogram example looks nothing like waveform's output, so I'm not sure what you're after, but in any case I think changing background colour is a bit outside waveform's remit, being meant only as a diagnostic filter. You could adjust the input video before adding waveform, or you could take waveform's output and use other filters on it, but for speed reasons all waveform does is shift the underlying pixel values one bit to the right.

2) Option to only display the the pure waveform without the the window marks (center ones are fine, is just when the window is set high the marks are very close together and become a little intrusive).

Done, but only as all-or-nothing.

3) Can anything be done to make waveform scroll a bit more smoothly?

Not really. It has to scroll a certain number of pixels per frame, and that's determined by the window size and the framerate of the video.

Reel.Deel
28th February 2015, 18:16
Thanks for the quick update, I tried v0.3, it fixes the things I mentioned above but unfortunately with window=50, zoom>=1.30 I get access violations (had not tried this combination before).

That histogram example looks nothing like waveform's output
I know, I should of been a little more clear. :)

for speed reasons all waveform does is shift the underlying pixel values one bit to the right.
This must be the color differences I'm seeing. color_yuv=$508080, left is correct, waveform output is not (at least the background). I guess I'll try to compensate for the color shift before waveform.
https://dl.dropboxusercontent.com/s/b1sc4z6ltw6f73y/waveform_color.png

foxyshadis
2nd March 2015, 09:30
3) Can anything be done to make waveform scroll a bit more smoothly?

You could bump the framerate way up.

BlockABoots
18th November 2015, 22:40
Is there anyway to adjust the sensitivity of the waveform?, im trying to use this to help me sync up my video game capture. Im using the firing of a gun to sort audio sync issues out, but the only thing is at the moment the waveform is picking up alot of 'background noise' from the game, ideally i would like to lower how much wavform picks up so it only really detects the gun firing and thus make it easier to sync the video up, is this possible?

wonkey_monkey
18th November 2015, 23:04
Only by filtering the audio before calling waveform, perhaps with SuperEQ (http://avisynth.nl/index.php/SuperEQ).

BlockABoots
18th November 2015, 23:15
Only by filtering the audio before calling waveform, perhaps with SuperEQ (http://avisynth.nl/index.php/SuperEQ).

Thats an idea, what freq would i want to select though for cutting out background noise??

foxyshadis
19th November 2015, 00:56
Use a free software called Sonic Visualiser (http://www.sonicvisualiser.org/); load a saved capture of the audio and use Layer->Add Spectrogram. This will show you the frequencies you're working with, from there you'll know how to adjust it to isolate one sound, or just visually find it (impulses are usually easy to see).

`Orum
2nd January 2016, 16:31
What is this licensed under?

I only ask as I've made some minuscule changes to update this for AviSynth 2.6 / AviSynth+, mainly because I wanted a 64-bit version of it. I've succeeded in doing so, and was going to upload it for others, but I can't legally do so without a license permitting me to do so.

If you (i.e. davidhorman) would prefer a patch and to compile/release your own binaries, that's fine too, it's literally adding 2 lines of code and changing 1 more. I'll post it if you want, and thanks for the great filter!

wonkey_monkey
2nd January 2016, 17:25
Hi Orum,

Please go ahead and consider waveform to be GPLv2.

`Orum
3rd January 2016, 21:12
Thanks. I've uploaded a zip containing the legal info, doc, and x64 and x86 bit builds--though I believe your x86 build works just fine even with AviSynth 2.6 / AviSynth+, I wasn't sure and it was trivial to include. Let me know if you have any issues with what I did and I'll rectify them.

You can download it here (https://www.dropbox.com/s/ufkw5w0nn79qzd5/waveform.zip?dl=0).

Please note that you must have the Visual C++ Redistributable for Visual Studio 2015 (https://www.microsoft.com/en-us/download/details.aspx?id=48145) installed for it to work.

wonkey_monkey
5th July 2018, 19:47
For what it's worth, I've added a hastily-complied x64 waveform.dll to the zip file:

http://horman.net/avisynth/download/waveform0.3.zip

Edit: ...having completely forgotten that `Orum had already ported it. Oh well!

xekon
29th September 2018, 17:36
Awesome Plugin! Any Hope for a Vapoursynth port?

wonkey_monkey
30th September 2018, 18:43
Awesome Plugin! Any Hope for a Vapoursynth port?

I was under the impression that VapourSynth has no audio support (or if it does, it's rudimentary and there is no built-in, standard way to do it).

Either way, the source code is there, but I have no interest in VapourSynth yet so it won't be me making the port.

StainlessS
22nd January 2019, 18:13
Wonkey,

Perhaps you would like to improve on this and include in the zip, not much tested.

SEE POST #41 for updated script:


Colorbars
WINDOW = 1 # Frames Wide = 2 * WINDOW + 1
HEIGHT = 0.333 # Audio graphs height, 0.333 = 1/3 of result filmstrip image height.
UNDER = True # True, then audio graphs stacked under video, else overlay over video.
ZOOM = 1.0 # Amplify audio signal for viewing (1.0=No Amp).
SUBSIZE = 0.2 # Suggest 0.0(off) to about 0.5. (Range:- 0.0 <= SubSize <= 1.0) ::: 0.0 = No Frame Number, 1.0=biggest size for current clip Height (probably too big).
###### Can Remove this lot ######
TONE = false # Replace Colorbars tone with selected TONETYPE tone
TONETYPE ="NOISE" # Pick from:- "Silence", "Sine", "Noise", "Square", "Triangle" or "Sawtooth"
TONECHANS = 5 # Tone Channels Count (test channels display)
#
(TONE) ? AudioDub(Tone(Length=FrameCount/FrameRate,Type=TONETYPE,Channels=TONECHANS)) : Last
###### End Of Can Remove ######

Return WaveForm_FilmStrip(window=WINDOW,Height=HEIGHT,under=UNDER,zoom=ZOOM,subSize=SUBSIZE)

Function WaveForm_FilmStrip(clip c,int "Window",Float "Height",Bool "Under",Float "Zoom",Bool "Marks",Float "SubSize") {
Window = Default(Window,0) Height = Max(Default(Height,0.333),0.0)
Under = Default(Under,True) SubSize = Default(SubSize,0.0)
Assert(0 <= window <= 3,"WaveForm_FilmStrip: 0 <= window <= 3")
Assert(0.0 <= SubSize <= 1.0,"WaveForm_FilmStrip: 0.0 <= SubSize <= 1.0")
Frms = 1 + (2*Window)
sc = c.BiCubicResize((c.Width+Frms)/(Frms*2)*2,(c.Height+Frms)/(Frms*2)*2,b=-0.5,c=0.25)
scSubsSz = Round(sc.Height*SubSize)
SSS="""Subtitle(String(current_frame,"%.0f"),""" + String(scSubsSz,"SIZE=%.0f,") + String((sc.Height-scSubsSz)/2.0,"Y=%.0f") + """,align=8)"""
sc = (scSubsSz!=0) ? sc.ScriptClip(SSS) : sc
p3c = sc.SelectEvery(1,-3) p2c = sc.SelectEvery(1,-2) p1c = sc.SelectEvery(1,-1)
n1c = sc.SelectEvery(1,1) n2c = sc.SelectEvery(1,2) n3c = sc.SelectEvery(1,3)
FilmStrip=Select(Window,sc,StackHorizontal(p1c,sc,n1c),StackHorizontal(p2c,p1c,sc,n1c,n2c),StackHorizontal(p3c,p2c,p1c,sc,n1c,n2c,n3c)).AudioDubEx(c).Trim(0,-c.FrameCount)
Return FilmStrip.WaveForm(window=Window,height=Height,under=Under,zoom=Zoom,marks=Marks)
}

EDITED:
https://i.postimg.cc/XX11TvG8/Waveform-X2.jpg (https://postimg.cc/XX11TvG8)
EDIT: With WINDOW=2 and TONE=True
https://i.postimg.cc/fV4QqSKG/Wave-Form-Film-Strip.jpg (https://postimg.cc/fV4QqSKG)
EDIT: Under=False
https://i.postimg.cc/LnrwHqJm/Film-Strip-Under.jpg (https://postimg.cc/LnrwHqJm)
WINDOW=3 [filmstrip 7 images wide]
https://i.postimg.cc/Lh0kbT3h/Wave-Form-Film-Strip7.jpg (https://postimg.cc/Lh0kbT3h)

EDIT: Inside Function, round'ed Subtitle Y postion, else cause problems in v2.58(which must be type Int).

wonkey_monkey
22nd January 2019, 18:30
sc = BiCubicResize(FWid,FHit) #.ShowFrameNumber

First improvement: never use bicubicresize with default parameters! It blurs:

https://forum.doom9.org/showthread.php?t=175681

Granted it's not going to make much difference in this case, but I am morally opposed to bicubicresize for this reason.

I don't think this functionality should be incorporated into waveform. A separate filmstrip plugin would be nice, and has benefits of its own without waveform - then just a shim of an Avisynth function is required to tie them together with the same Window.

Why didn't you use under=true?

Edit: dammit now I'm going to have to write a filmstrip plugin because otherwise I won't stop thinking about writing a filmstrip plugin.

StainlessS
22nd January 2019, 18:49
OK, fixed to

sc = BiCubicResize(FWid,FHit,b=-0.5,c=0.25) #.ShowFrameNumber


From here:- https://forum.doom9.org/showthread.php?t=174496

Bicub_b, BicubicResize() b and c args. (If supplied as args, BEST SUPPLY BOTH Bicub_b and Bicub_c)
Bicub_c Default:-
DownSize b = -0.5, c = 0.25, Groucho2004,Didée:- https://forum.doom9.org/showthread.php?p=1802716#post1802716
Upsize, b = 0.0, c = 0.5, Catmull-Rom spline, sharp.
Avisynth BicubicResize() defaults are:- b=1.0/3, c=1.0/3


I meant to just include avs in zip, it does a fair job, mod as you will (change resizer if you will).
EDIT: Script should be sufficient for a filmstrip, dont bother with new plugin, more work for little return.

EDIT:
Why didn't you use under=true?
Mod as you will.

wonkey_monkey
22nd January 2019, 21:26
Oh okay, sure, I can include it when I get round to fixing the left/right swap. But I think I may have written a filmstrip plugin by then, because the idea won't go away now...

warp was a diversion from another project. Right now I'm writing another diversion from that project, and now there's another on the list (but I don't blame you). I hate my brain sometimes.

StainlessS
22nd January 2019, 21:40
because the idea won't go away now...

Thanks muchly, now I know how to screw with your head https://www.cosgan.de/images/smilie/frech/o080.gif

Emulgator
22nd January 2019, 21:47
Waveform. And Filmstrip. I like it. We're getting closer to Vegas ;-),
then morph the filmstrip tiny when off center, apple taskbar, drool... ;-)

StainlessS
23rd January 2019, 00:35
Post #33 updated, moved Subtitling into function.

EDIT: Added Height, and Under args.

EDIT: How would Vegas et al, show non existing end frames, where eg WINDOW=1 (3 images wide),
at Filmstrip result frame 0, would image & audio for image representing frame previous to frame 0
be shown same as image for frame 0, or would it be eg BLACK/GREY and with silent audio,
or something else ???

eg this one, what should left image contain ? [current frame is center image 0 with hi-lited audio]
https://i.postimg.cc/tYmGmLYw/Wave-Form-Film-Strip-double0.jpg (https://postimg.cc/tYmGmLYw)

EDIT: Wonkey [NoteToSelf: Must remember to get my vowels right],
I thought there was a problem in WaveForm, as it shows audio for frame prior to frame 0

#AviSource("D:\G.avi")
Colorbars

Trim(0,-100) # Does NOT fix AUDIO [Should trim/pad audio to same length as video]

FIXAUDIO = False # On showing Frame 0, IF TRUE, Nullifies audio for frame=-1
(FIXAUDIO) ? ShowFrameNumber : NOP # If ShowFramenumber, nullifies audio for non existing frame [returns null audio for invalid audio ranges]
WaveForm(Window=1)

FIXAUDIO= TRUE fixes problem and shows null audio at frame -1 [ShowFrameNumber filter fixes caching problem in Colorbars],
not sure if there is a slight problem in AVS/+ due to caching audio for ColorBars
[obviously frame -1 cannot have any audio, (or can it, what about unaligned splice, does audio always start @ 0 ???, or what about DelayAudio(NegativeNumber))].
Using AviSource instead of colorbars produces no audio for frame -1, and so does not need above fix.
Avs valid frame range limiting limits video frames 0 -> Framecount-1, If out of range frame requested, returns frame number nearest to out of range frame.
Audio should be similarly limited, but should return null audio where out of audio sample range [methinks].
Trim should both limit overlength audio and pad underlength audio, I use it all of the time for that purpose.

Not sure if this subject has come up before, think I recall someone asking about which filters can actually force a proper audio trim() [as in ShowFrameNumber above], but with least overhead and effect.
[bit daft having to have a filter that behaves exactly like trim should do, perhaps we need a Trim(Bool DontReallyTrimAudio) arg, and make default to DontReallyTrimAudio=False ]

FIXAUDIO=False [Frame = -1 has audio]
https://i.postimg.cc/4KZSBgzz/Fix-Audio-False.jpg (https://postimg.cc/4KZSBgzz)
FIXAUDIO=True [Frame = -1 has null (silent) audio]
https://i.postimg.cc/xkRFZ4RB/Fix-Audio-True.jpg (https://postimg.cc/xkRFZ4RB)

StainlessS
26th January 2019, 22:11
EDIT: Wonkey, x64 dll (v0.3 zip) seems not to have the Marks arg, perhaps an older version dll.
Update on WaveForm_FilmStrip(),
Frames prior to frame 0, and after FrameCount-1, shown as black, and without frame numbering.
Colorbars AUDIO prior to frame 0, and after FrameCount-1, now shows as silent, was driivng me nuts that Trim was not trimming audio [or rather that it was not making invalid audio silent].
[DelayAudio(0.0) does a proper trim on the audio, thank goodness].
EDIT: Added ShowAudio arg.

EDIT: SCRIPT_REMOVED: See post 41

Showing @ frame 0 where Window=2.
https://i.postimg.cc/8j2gHnFg/Film-Strip-Audio-Fixed.jpg (https://postimg.cc/8j2gHnFg)

StainlessS
27th January 2019, 14:22
WaveForm_FilmStrip Update, added W, H args, Width, Height of FilmStrip thumbnail images.
Hope this is Final version.


#AviSource("D:\G.avi")
Colorbars.Trim(0,-100)

WINDOW = 1 # Frames Wide = 2 * WINDOW + 1
HEIGHT = 1.0 # Audio graphs height, 0.333 = 1/3 of result filmstrip image height.
UNDER = True # True, then audio graphs stacked under video, else overlay over video.
ZOOM = 1.0 # Amplify audio signal for viewing (1.0=No Amp).
SUBSIZE = 0.5 # Suggest 0.0(off) to about 0.5. (0.0 <= SubSize <= 1.0) : 0.0 = No Frame Number, 1.0=biggest size for current clip Height (probably too big).
SHOWAUDIO = True # Default True. If False, Switches OFF WaveForm Display, Shows FilmStrip Only.
W = -1 # Default -1, (or 0 or +ve). -1 = Normal Downscale behaviour, filmstrip width ~= input clip width.
H = Undefined # Undefined, Let W govern height of thumbnail images (or just dont use h=H in function call, same as h=Undefined).

###### Can Remove this lot ######
TONE = False # Replace Colorbars tone with selected TONETYPE tone
TONETYPE ="NOISE" # Pick from:- "Silence", "Sine", "Noise", "Square", "Triangle" or "Sawtooth"
TONECHANS = 5 # Tone Channels Count (test channels display)
#
(TONE) ? AudioDub(Tone(Length=FrameCount/FrameRate,Type=TONETYPE,Channels=TONECHANS)) : Last
###### End Of Can Remove ######

Return WaveForm_FilmStrip(window=WINDOW,Height=HEIGHT,under=UNDER,zoom=ZOOM,subSize=SUBSIZE,ShowAudio=SHOWAUDIO,w=W,h=H)

Function WaveForm_FilmStrip(clip c,int "Window",Float "Height",Bool "Under",Float "Zoom",Bool "Marks",Float "SubSize",Bool "ShowAudio",Int "W",Int "H") {
/* Waveform_FilmStrip:- by StainlessS @ Doom9 ::: https://forum.doom9.org/showthread.php?p=1863963#post1863963
Where ShowAudio=True, Requires WaveForm plugin (c) Wonkey_Monkey, https://forum.doom9.org/showthread.php?t=165703
[Wonkey_Monkey, The Prince formerly known as David.]

WaveForm_FilmStrip(clip c,int "Window"=0,Float "Height"=0.333,Bool "Under"=True,Float "Zoom"=1.0,Bool "Marks"=True,Float "SubSize"=0.0,Bool "ShowAudio"=True,Int "W"=-1,Int "H"=W_Based)

Window, Default 1 (0 <= Window <=3), Filmstrip thumbnail Images across = 2 * Window + 1.
Height, Default 0.333=1/3 of FilmStrip Height. See Waveform docs for more.
Under, Default True, If True, then audio graph stacked under video, else overlay over video.
Zoom, Default 1.0. Amplify audio signal for viewing (1.0=No Amp).
SubSize, Default 0.0(0.0 <= SubSize <= 1.0). Suggest 0.0(No Frame Number) to about 0.5. : 1.0=biggest size for current clip Height (probably too big).
ShowAudio, Default True. If False, Switches OFF WaveForm Display, Shows FilmStrip Only.
W, Default -1. Governs width of thumbnail images making up the FilmStrip.
-ve) Entire FilmStrip width (multiple thumbnail images based on Window arg) will be about same as input clip width.
0) Each FilmStrip thumbnail image is SAME size as input clip, result could be a quite wide clip.
Else) Each FilmStrip thumbnail image Width is set by W (best Mod 2).
H, Default based off W. (Suggest Dont supply H arg, let it default based on W arg. Can call with H=Undefined where will behave as if defaulting).
IF H is Supplied ie not defaulted THEN H = Supplied H # could be -ve, 0, or +ve(explicit height).
else if W <= 0, then H = W, ELSE H = input clip height Aspect Ratio Scaled to match W.
Here, H could be -ve, 0, or +ve, defaulted or non defaulted.
Where H,
-ve) FilmStrip height scaled down to Aspect Ratio match FilmStrip width of individual thumbnail images.
0) Each FilmStrip thumbnail image Height is SAME size as input clip height.
Else) Each FilmStrip thumbnail image Height is set by H (best Mod 2).
*/
Window=Default(Window,0) Height=Max(Default(Height,0.333),0.0) Under=Default(Under,True) SubSize=Default(SubSize,0.0) ShowAudio=Default(ShowAudio,True)
W=Default(W,-1) H=Default(H,W<=0?W:Round(W.Float/c.Width*c.Height+1)/2*2)
Assert(0 <= window <= 3,"WaveForm_FilmStrip: 0 <= window <= 3")
Assert(0.0 <= SubSize <= 1.0,"WaveForm_FilmStrip: 0.0 <= SubSize <= 1.0")
Frms = 1 + (2*Window) WW=(W<0)?(c.Width+Frms)/(Frms*2)*2:(W==0)?c.width:W HH=(H<0)?(c.Height+Frms)/(Frms*2)*2:(H==0)?c.Height:H
sc=(WW!=c.Width||HH!=c.Height) ?c.BiCubicResize(WW,HH,b=-0.5,c=0.25) :c scSubsSz=Round(sc.Height*SubSize)
SSS="""Subtitle(String(current_frame,"%.0f")""" + String(scSubsSz,",SIZE=%.0f") + String((sc.Height-scSubsSz)/2.0,",Y=%.0f") + """,align=8)"""
sc=(scSubsSz!=0)?sc.ScriptClip(SSS):sc bc=sc.BlankClip(Length=1,Color=$000000)
p1c=bc+sc p2c=bc+p1c p3c=bc+p2c
n1c=sc.FrameCount>1?sc.Trim(1,0)+bc:bc n2c=n1c.FrameCount>1?n1c.Trim(1,0)+bc:bc n3c=n2c.FrameCount>1?n2c.Trim(1,0)+bc:bc
Select(Window,sc,StackHorizontal(p1c,sc,n1c),StackHorizontal(p2c,p1c,sc,n1c,n2c),StackHorizontal(p3c,p2c,p1c,sc,n1c,n2c,n3c))
\ .AudioDubEx(c).Trim(0,-c.FrameCount).DelayAudio(0.0)
return (ShowAudio && HasAudio) ? WaveForm(window=Window,height=Height,under=Under,zoom=Zoom,marks=Marks) : Last
}

https://i.postimg.cc/PpkF4wfQ/Wave-Form-Film-Strip.jpg (https://postimg.cc/PpkF4wfQ)

StainlessS
12th June 2019, 16:41
Small mod in blue, round size DOWN rather than nearest, easier to addborders to filmstrip to match up with original clip width. -ve H also now round down rather than nearest.
W, -ve) Entire FilmStrip width (multiple thumbnail images based on Window arg) will be about same [smaller or equal] as input clip width.


Function WaveForm_FilmStrip(clip c,int "Window",Float "Height",Bool "Under",Float "Zoom",Float "SubSize",Bool "ShowAudio",Int "W",Int "H") {
/* Waveform_FilmStrip:- by StainlessS @ Doom9 ::: https://forum.doom9.org/showthread.php?p=1965005#post1965005
Where ShowAudio=True, Requires WaveForm v2.0 plugin (c) Wonkey_Monkey, https://forum.doom9.org/showthread.php?t=182866
[Wonkey_Monkey, The Prince formerly known as David.]

WARNING - Marks arg no longer a setting in WaveForm v0.3 x64 or v2.0 - so removed from WaveForm_FilmStrip
Also, Made Under default False as Suggested by Wonkey.

WaveForm_FilmStrip(clip c,int "Window"=0,Float "Height"=0.333,Bool "Under"=FALSE,Float "Zoom"=1.0,Float "SubSize"=0.0,Bool "ShowAudio"=True,Int "W"=-1,Int "H"=W_Based)

Window, Default 1 (0 <= Window <=3), Filmstrip thumbnail Images across = 2 * Window + 1.
Height, Default 0.333=1/3 of FilmStrip Height. See Waveform docs for more.
Under, Default False, If True, then audio graph stacked under video, else overlay over video.
Zoom, Default 1.0. Amplify audio signal for viewing (1.0=No Amp).
SubSize, Default 0.0(0.0 <= SubSize <= 1.0). Suggest 0.0(No Frame Number) to about 0.5. : 1.0=biggest size for current clip Height (probably too big).
ShowAudio, Default True. If False, Switches OFF WaveForm Display, Shows FilmStrip Only.
W, Default -1. Governs width of thumbnail images making up the FilmStrip.
-ve) Entire FilmStrip width (multiple thumbnail images based on Window arg) will be about same [smaller or equal] as input clip width.
0) Each FilmStrip thumbnail image is SAME size as input clip, result could be a quite wide clip.
Else) Each FilmStrip thumbnail image Width is set by W (best Mod 2).
H, Default based off W. (Suggest Dont supply H arg, let it default based on W arg. Can call with H=Undefined where will behave as if defaulting).
IF H is Supplied ie not defaulted THEN H = Supplied H # could be -ve, 0, or +ve(explicit height).
else if W <= 0, then H = W, ELSE H = input clip height Aspect Ratio Scaled to match W.
Here, H could be -ve, 0, or +ve, defaulted or non defaulted.
Where H,
-ve) FilmStrip height scaled down to Aspect Ratio match FilmStrip width of individual thumbnail images.
0) Each FilmStrip thumbnail image Height is SAME size as input clip height.
Else) Each FilmStrip thumbnail image Height is set by H (best Mod 2).
*/
Window=Default(Window,0) Height=Max(Default(Height,0.333),0.0) Under=Default(Under,false) SubSize=Default(SubSize,0.0) ShowAudio=Default(ShowAudio,True)
W=Default(W,-1) H=Default(H,W<=0?W:Int(W.Float/c.Width*c.Height)/2*2)
Assert(0 <= window <= 3,"WaveForm_FilmStrip: 0 <= window <= 3")
Assert(0.0 <= SubSize <= 1.0,"WaveForm_FilmStrip: 0.0 <= SubSize <= 1.0")
Frms = 1 + (2*Window) WW=(W<0)?c.Width/(Frms*2)*2:(W==0)?c.width:W HH=(H<0)?c.Height/(Frms*2)*2:(H==0)?c.Height:H
sc=(WW!=c.Width||HH!=c.Height) ?c.BiCubicResize(WW,HH,b=-0.5,c=0.25) :c scSubsSz=Round(sc.Height*SubSize)
SSS="""Subtitle(String(current_frame,"%.0f")""" + String(scSubsSz,",SIZE=%.0f") + String((sc.Height-scSubsSz)/2.0,",Y=%.0f") + """,align=8)"""
sc=(scSubsSz!=0)?sc.ScriptClip(SSS):sc bc=sc.BlankClip(Length=1,Color=$000000)
p1c=bc+sc p2c=bc+p1c p3c=bc+p2c
n1c=sc.FrameCount>1?sc.Trim(1,0)+bc:bc n2c=n1c.FrameCount>1?n1c.Trim(1,0)+bc:bc n3c=n2c.FrameCount>1?n2c.Trim(1,0)+bc:bc
Select(Window,sc,StackHorizontal(p1c,sc,n1c),StackHorizontal(p2c,p1c,sc,n1c,n2c),StackHorizontal(p3c,p2c,p1c,sc,n1c,n2c,n3c))
\ .AudioDubEx(c).Trim(0,-c.FrameCount).DelayAudio(0.0)
return (ShowAudio && HasAudio) ? WaveForm(window=Window,height=Height,under=Under,zoom=Zoom) : Last
}


client

#AviSource("D:\G.avi")
Colorbars.Trim(0,-100)

WINDOW = 3 # Frames Wide = 2 * WINDOW + 1
HEIGHT = 0.33 # Audio graphs height, 0.333 = 1/3 of result filmstrip image height.
UNDER = false # True, then audio graphs stacked under video, else overlay over video.
ZOOM = 1.0 # Amplify audio signal for viewing (1.0=No Amp).
SUBSIZE = 0.5 # Suggest 0.0(off) to about 0.5. (0.0 <= SubSize <= 1.0) : 0.0 = No Frame Number, 1.0=biggest size for current clip Height (probably too big).
SHOWAUDIO = True # Default True. If False, Switches OFF WaveForm Display, Shows FilmStrip Only.
W = 264 # Default -1, (or 0 or +ve). -1 = Normal Downscale behaviour, filmstrip width ~= input clip width.
#H = Undefined # Undefined, Let W govern height of thumbnail images (or just dont use h=H in function call, same as h=Undefined).

###### Can Remove this lot ######
TONE = False # Replace Colorbars tone with selected TONETYPE tone
TONETYPE ="NOISE" # Pick from:- "Silence", "Sine", "Noise", "Square", "Triangle" or "Sawtooth"
TONECHANS = 5 # Tone Channels Count (test channels display)
#
(TONE) ? AudioDub(Tone(Length=FrameCount/FrameRate,Type=TONETYPE,Channels=TONECHANS)) : Last
###### End Of Can Remove ######
WaveForm_FilmStrip(window=WINDOW,Height=HEIGHT,under=UNDER,zoom=ZOOM,subSize=SUBSIZE,ShowAudio=SHOWAUDIO,w=W) #,h=H)
Return Last


Window=3 W=128 [individual thumb width = 128 : Full width (Window*2+1)*128 = 7*128=896 ]
https://i.postimg.cc/26N4fw7f/Wave-Form-Film-Strip-00.jpg (https://postimages.org/)

Window=3 W=-1(total width smaller or equal original width[640], out width=630[each thumb width mod 2, ie (Window*2+1)*90 = 7*90=630])
https://i.postimg.cc/SxX825Zh/Wave-Form-Film-Strip-01.jpg (https://postimages.org/)

EDIT: Removed Marks arg, Made Under default False as Wonkey suggestion.

StainlessS
5th August 2019, 17:08
Wonkey, can we have some kind of center/zero marking, ta. [EDIT: maybe dotted, eg every 4th pixel]

wonkey_monkey
5th August 2019, 17:32
I'll bear it in mind for the next version. For now, you could create a second video with amplify(0) and overlay/layer it with the first, maybe with mode = "lighten" or some variation of that.

StainlessS
5th August 2019, 17:49
No great urgency W, takes your time.
Thank you for your consideration :)

StainlessS
11th November 2019, 11:06
Mod to dotted request, maybe eg every 4th pixels, with alternate black/white dots.

hello_hello
2nd January 2020, 08:55
wonkey_monkey,

The link in the opening post is labelled waveform0.3.zip, but the file that downloads is waveform0.2.zip, which seems odd as the link location is http://horman.net/waveform0.3.zip

PS The link in post 20 downloads waveform0.3.zip which I assume is the correct one.
http://horman.net/avisynth/download/waveform0.3.zip

Cheers.

wonkey_monkey
2nd January 2020, 10:50
That's my stupid web host trying to be helpful. Fixed.

StainlessS
11th February 2020, 17:41
Wonkey, can you please delete links in these two posts [to old v0.2, 2nd link says 0.3 and even name on server says 0.3 but is 0.2]
Post #11, https://forum.doom9.org/showthread.php?p=1589325#post1589325 [EDIT: This link actually says v0.2, maybe you decide to keep it]
Post #30, https://forum.doom9.org/showthread.php?p=1845947#post1845947

EDIT: Hello_Hello post [2 ahead] has correct link, as does 1st post link, and so does your "My Avisynth Filters" link.

hello_hello
11th February 2020, 21:45
StainlessS,
I appear to have overlooked your WaveForm_FilmStrip() function until now. Maybe I didn't understand it or didn't pay enough attention at the time, but I made a similar (https://forum.videohelp.com/threads/384967-AudioSpeed-AudioMeter-AudioWave-scripts) a while back, originally only displaying meters, as I didn't discover the WaveForm plugin until somewhat recently. Minus your filmstrip idea though, because I'm not smart enough to think of that.

It's probably the definition of pointless, but it amused me watching the kids play together. :)

AudioWaveL(FT=true, Zoom=5.0)
WaveForm_FilmStrip(Window=1, Zoom=5.0)

https://i.postimg.cc/LJyv8c5M/waves.jpg (https://postimg.cc/LJyv8c5M)

AudioMeterR(FT=true)
WaveForm_FilmStrip(Window=1, Zoom=5.0)

https://i.postimg.cc/XZpLGsBB/meters.jpg (https://postimg.cc/XZpLGsBB)