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 4th May 2013, 00:09   #21  |  Link
Keiyakusha
契約者
 
Keiyakusha's Avatar
 
Join Date: Jun 2008
Posts: 1,576
Quote:
Originally Posted by poisondeathray View Post
Can you explain what you have in mind ? Some non linear scaling ?
Something like this (^_^)

Code:
#yv12 source
Spline36resize(1280,720)
w=width()
Audiodub(blankclip(last),last)
Converttomono()
Normalize()
pointresize(1280,720)
Converttoyv24()
Histogram(mode="audiolevels")
Converttorgb32(chromaresample="point")
calc=FrameRate()*1280/Framecount()
Changefps(calc,linear=false).Trim(0,-w)
Crop(100,0,-1179,-360)
WeaveColumns(1280)
Greyscale()
Levels(0, 1.000, 1, 0, 255, coring=false)
aa=Crop(0,0,0,-height*3/4)
bb=Crop(0,height/4,0,-height/2)
cc=Crop(0,height/2,0,-height/4)
dd=Crop(0,height*3/4,0,0)
aa=pointresize(aa,width(aa), height(aa))
bb=pointresize(bb,width(bb), height(bb)/6)
cc=pointresize(cc,width(cc), height(cc)/9)
dd=pointresize(dd,width(dd), height(dd)/12)
Stackvertical(aa,bb,cc,dd)
blur(1)
F/sn UBV theatrical teaser


Edit: no blur

Last edited by Keiyakusha; 4th May 2013 at 00:15.
Keiyakusha is offline   Reply With Quote
Old 4th May 2013, 00:11   #22  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 3,926
That looks improved

No blur looks better to me; or maybe add a configurable parameter

You can always add blur after the overlay/composite ; I think it's better to have sharp edges since the same image can also be used as a luma matte (or mask in overlay() )

Last edited by poisondeathray; 4th May 2013 at 00:35.
poisondeathray is offline   Reply With Quote
Old 4th May 2013, 01:16   #23  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,395
my (debian) ffmpeg / imagemagick try (1 strip = 1 frame)
Code:
#!/bin/bash

# produces a color-stripe (color fingerprint) png of a video file (1 pixel = 1 frame)

while [ $# -gt 0 ]; do

# make temporary folder and trap to clean up
TMPDIR=`mktemp -d`
trap "rm -rf $TMPDIR" EXIT

# expand path, so this can be used from cli as well (on relative paths)
# file=$(readlink -f "$1")
 file="$1"

ffmpeg -i "$file" -sws_flags neighbor -vf scale=2:2 -f image2 "$TMPDIR/out-%05d.png"
convert +append "$TMPDIR/out-*.png" -resize 1x1\! -resize 1x128\! "$file.png"

rm -rf $TMPDIR

    shift
done
(didn't bother with audio and could not figure out how to pipe ffmpeg to convert, improvements welcome)

examples:
http://shrani.si/f/16/OU/3fUvCjIb/shakira-loca.png
http://shrani.si/f/2Z/Mh/2eV7odGN/psy.png
__________________
certain other member

Last edited by smok3; 4th May 2013 at 20:12.
smok3 is offline   Reply With Quote
Old 4th May 2013, 02:17   #24  |  Link
Keiyakusha
契約者
 
Keiyakusha's Avatar
 
Join Date: Jun 2008
Posts: 1,576
smok3
Yeah, I mentioned batch-scripted imagemagick before. But we also need to make that result match to the given video horizontally, attach to the bottom and make it reveal itself over time like a slider. And this is a bit more complicated...


ok, back to the audio. New update. Not sure If I can make adjustable height as instead of proper nonlinear scaling I just chained few usual resamplers, and simulating this "feather"...
some bicubicresize probably can be replaced to pointresize with no harm but with speedup... not sure.
Edit: or actually this is super simple? just need to set any kind of height in last bicubicresize call? Hmm...
Code:
#1280x720 yv12 input with audio. nothing else tested.
w=width()
AudioDub(BlankClip(last,pixel_type="YV24",width=1280,height=720),last)
Converttomono().Normalize()
Histogram(mode="audiolevels").Converttorgb32()
calc=FrameRate()*w/Framecount()
Changefps(calc,linear=false).Trim(0,-w)
Crop(100,0,-1179,-0188)
Greyscale().Levels(0,1.000,64,0,255,coring=false)
WeaveColumns(w).Greyscale()
e=Crop(0,0,0,-height*3/4)
f=Crop(0,height/4,0,-height/2)
g=Crop(0,height/2,0,-height/4)
h=Crop(0,height*3/4,0,0)
e=bicubicresize(e,width(e),height(e)/2)
f=bicubicresize(f,width(f),height(f)/6)
g=bicubicresize(g,width(g),height(g)/9)
h=bicubicresize(h,width(h),height(h)/12)
Stackvertical(e,f,g,h)
bicubicresize(width,48)
bicubicresize(width,6).addborders(0,1,0,0)
bicubicresize(width,48)
F/sn UBV theatrical teaser. This is constant music though, trailer for american movie probably will look more "uneven" like that thing on youtube. Or maybe not. Also I wonder how ugly it will look when overlayed...

Last edited by Keiyakusha; 4th May 2013 at 02:37.
Keiyakusha is offline   Reply With Quote
Old 4th May 2013, 04:33   #25  |  Link
Keiyakusha
契約者
 
Keiyakusha's Avatar
 
Join Date: Jun 2008
Posts: 1,576
ok, here is function for video AND audio combined. All standard resolutions as input should work.
Probably needs some tweaking though, to make it look more like that thing on YT.
I wanted waveform to be around 30% of the video fingerprint height. Not sure if it is right or I failed basic math, or maybe I did some other mistake.
Code:
function fingerprint(clip source, int "fph"){
w=width(source)
v=crop(source,8,8,-8,-8)
v=bicubicresize(v,640,360)
calc=FrameRate(v)*w/Framecount(v)
v=Changefps(v,calc,linear=false).Trim(0,-w)
v=converttorgb32(v).bicubicresize(4,4).blur(0.65).bilinearresize(2,2)
a=Crop(v,0,0,-1,-1)
b=Crop(v,1,0,0,-1)
c=Crop(v,0,1,-1,0)
d=Crop(v,1,1,0,0)
x=Overlay(a,b,mode="blend",opacity=0.5)
y=Overlay(c,d,mode="blend",opacity=0.5)
v=Overlay(x,y,mode="blend",opacity=0.5)
v=pointresize(v,1,fph)
v=WeaveColumns(v,w).Converttoyv12()
wf=AudioDub(BlankClip(source,pixel_type="YV24",width=1280,height=720),source)
wf=Converttomono(wf).Normalize()
wf=Histogram(wf,mode="audiolevels").Converttorgb32()
wf=Changefps(wf,calc,linear=false).Trim(0,-w)
wf=Crop(wf,100,0,-1179,-0188)
wf=Greyscale(wf).Levels(0,1.000,64,0,255,coring=false)
wf=WeaveColumns(wf,w)
e=Crop(wf,0,0,0,-height(wf)*3/4)
f=Crop(wf,0,height(wf)/4,0,-height(wf)/2)
g=Crop(wf,0,height(wf)/2,0,-height(wf)/4)
h=Crop(wf,0,height(wf)*3/4,0,0)
e=bicubicresize(e,width(e),height(e)/2)
f=bicubicresize(f,width(f),height(f)/6)
g=bicubicresize(g,width(g),height(g)/9)
h=bicubicresize(h,width(h),height(h)/12)
wf=Stackvertical(e,f,g,h)
wf=bicubicresize(wf,w,48)
wf=bicubicresize(wf,w,6).addborders(0,1,0,0)
wf=bicubicresize(wf,w,fph*30/100).addborders(0,fph-fph*30/100,0,0)
v=Overlay(v,wf,mode="Add",opacity=0.333)
bg=blankclip(width=w,height=fph)
v=StackVertical(source,v)
Function ovl(clip c1, clip c2, int xx, int yy) { Overlay(c1, c2 , xx , yy) }
v=Animate(v,0,source.framecount+1,"ovl", bg,0,source.height,   bg,source.width,source.height)
return v
}
fingerprint(fph=128)

Looks like this.

Last edited by Keiyakusha; 4th May 2013 at 04:43.
Keiyakusha is offline   Reply With Quote
Old 4th May 2013, 09:12   #26  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,395
Quote:
Yeah, I mentioned batch-scripted imagemagick before. But we also need to make that result match to the given video horizontally, attach to the bottom and make it reveal itself over time like a slider. And this is a bit more complicated...
Yeah, ill skip that part, but if you have a (working) ffmpeg>convert piping solution don't be shy to post.
__________________
certain other member
smok3 is offline   Reply With Quote
Old 11th May 2013, 17:10   #27  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,810
Coming soon...

From the Man of Steel trailer:



More info and a plugin soon.
wonkey_monkey is offline   Reply With Quote
Old 6th June 2013, 19:56   #28  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,810
Whoops, never got around to providing this.

First you'll need the plugin from here.

Then you can use this function to apply it (probably bad to give the function the same name as the filter, but whatever):

Code:
function fingerprint(clip a, int h) {
  rgb=a.converttorgb32
  resized=rgb.bicubicresize(a.width,h)
  fingerprinted=resized.fingerprint
  stack=stackvertical(rgb,fingerprinted.bicubicresize(rgb.width,fingerprinted.height))
  return stack
}
You'll get gaps if you seek around in the video without playing it in sequence first, but that also means it doesn't have to preload the clip.

It forces the clip to RGB32 with the default matrix (rec601) so you'll need to bear that in mind if you want to convert it back to the original format.

David
wonkey_monkey is offline   Reply With Quote
Old 7th June 2013, 00:49   #29  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 903
Thanks for the plugin, davidhorman.
Interesting take on the fingerprint.

---
I've found a Windows program that can generate a favorable waveform, but it's only a matter of finding a decent way to normalize the audio.
It requires a physical WAV/MP3 file to work with and produces a PNG.

Depending what approach you take to normalize or level out the audio without it peaking, you'll get very different waveforms generated.
You can set the WxH dimensions for the PNG but if the audio peaks, the waveform will disappear off the picture.

Maybe use SoX to apply compand to each channel and then downmix to mono and normalize?
I want the lowest point of the wave form to not be at the center of the X-axis. About 1/3 to 1/2 would be nice to make it appear larger as a waveform.
And without it peaking beyond the given dimensions of the PNG frame.

I'll find the link to the Windows app. I believe there's a python extension for it or a PHP extension.
Also will post several examples of what I'm currently doing with the generated waveforms and video fingerprints.

ALSO, for full feature length films (much longer than trailers!), I got some error about nonlinear access?
I can't remember, but I just added it to the Keiyakusha/poisondeathray fingerprint script and it was able to handle full length films and allow seeking at any point in VirtualDub (quite a bit of time to load the whole project lol).

Updates and progress coming soon once I get things sorted.
__________________
Win10 (x64) build 18362| GPU Caps Viewer 1.42.4.0
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
Intel Xeon X5660 @2.80GHz
Sparktank is offline   Reply With Quote
Old 10th June 2013, 17:30   #30  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,092
David,

Using this

Code:
Avisource("D:\avs\test.avi")#.Trim(0,-2*1280)

function fingerprint(clip a, int h) {
  rgb=a.converttorgb32
  resized=rgb.bicubicresize(a.width,h)
  fingerprinted=resized.fingerprint
  stack=stackvertical(rgb,fingerprinted.bicubicresize(rgb.width,fingerprinted.height))
  return stack
}

Last.fingerprint(128)
I get, "Iinvalid arguments to function fingerprint".


changing to
Code:
Avisource("D:\avs\test.avi")#.Trim(0,-2*1280)

function fingerprintB(clip a, int h) {
  rgb=a.converttorgb32
  resized=rgb.bicubicresize(a.width,h)
  fingerprinted=resized.fingerprint
  stack=stackvertical(rgb,fingerprinted.bicubicresize(rgb.width,fingerprinted.height))
  return stack
}

Last.fingerprintB(128)
"There is no function named fingerprint".

How should it be called (and yes, probably a bad idea to have same name function as plugin, as user function name overrides plugin_name/builtin_Avisynth_name).

@Keiyakusha, you've made "fph" an optional argument, without a default.

EDIT: I'm also seeing a date of 11 May 2013 for the Fingerprint.dll ? EDIT: Oops, thats the day you made first post on it.

EDIT: I seem to recall a plugin called WarpResize.
__________________
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; 10th June 2013 at 17:53.
StainlessS is offline   Reply With Quote
Old 11th June 2013, 11:42   #31  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,810
I've only recently moved over to Avisynth 2.6. Do you have 2.5.8? Maybe I did something wrong in compiling it...

David
wonkey_monkey is offline   Reply With Quote
Old 11th June 2013, 12:02   #32  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,092
Nope, I'm using 2.6a4 almost exclusively.

I know you believe you are a bit messy and dont like to reveal your source, but if you would like me to take a peek
I'll be happy to. PM me a link if you like. I've done a number of 2.6 plugs and they seem to work OK.

I had myself started out doing a Fingerprint plugin, but discarded it what I saw that you had posted one already
(had only just spent about 1/2 hour on it so was far from doing anything).

EDIT: Nice job on the fingerprint strip you posted, looks great.
__________________
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; 11th June 2013 at 12:05.
StainlessS is offline   Reply With Quote
Old 14th June 2013, 02:12   #33  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 903
David,

I'm using the same AVS StainlessS is using and can't get your Fingerprint to run.
It crashes instantly in VirtualDub with something about a "kernal" crash.
Hopefully you and StainlessS can find something. It would be fun to use both forms of the fingerprint.
__________________
Win10 (x64) build 18362| GPU Caps Viewer 1.42.4.0
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
Intel Xeon X5660 @2.80GHz
Sparktank is offline   Reply With Quote
Old 14th June 2013, 04:58   #34  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 903
Updates with pictures.

So using an earlier Fingerprint as a function, I took a fingerprint of The Hobbit (2D version) in 1080p Blu-Ray resolutions.
I used one that doesn't work with audio just so I can get a huge color palette of the total movie.



For the waveform, I converted the DTS-HD MA (8ch) to separate WAVs with eac3to and used NicAudio to load the first 6 channels and normalize each before merging and converting to mono to run through "waveform generator". I saved the mono wav using BeHappy.

I found a Windows program that can generate a waveform in PNG formats.
It can also be used as a JavaScript or PHP function too.
It's initially a CLI app. I can't remember where I found a compiled binary package.
Here's the Github for the source code.
https://github.com/superjoe30/waveform

waveform generator can read mono wav files in the valid integer bit depths as well as IEE float (32).
It will tell you if there's a header chunk not found and will still generate waveforms saved in PNG with transparency.
Haven't tested with multichannel wavs though.

Here's the different results you can get depending on the settings you use.
There's three to toy with: inner, outer and background. The inner/outer refer to the inner part of the waveform or the outer tips.
Works in gradient color (rrggbbaa). ("a" for alpha transparency?)
To get full transparency on both the outer and inner part of the waveform on a black background, use:
--color-bg 000000ff --color-center 00000000 --color-outer 00000000

It produced these for me...
Inner: black, outer: red, background: transparent
http://i.imgur.com/M24ViZp.png

Inner: black, outer: red, background: black
http://i.imgur.com/5kyShHp.png

Inner: red, outer: red, background: black
http://i.imgur.com/XOkSOe6.png

Using transparency on both the inner/outer on black bg, I mixed it with the fingerprint in a photo editing program to get...

(open image in new tab for better viewing)

I had to brighten it a little to show more of the lower volumes.

I then split it half and saved the top/bottom halves to new files and took screenshots of the movie to make different wallpapers.
I also reduced the height of the pictures. I reduced the pictures of the colored waveforms to fit in the black bars of the screenshots from the movie.

Wallpaper 1 in 1920x1080 (open image in new tab for better viewing)


Wallpaper 2 in 1920x1080 (open image in new tab for better viewing)


Wonderful use!
The results are much better than I had hoped!
Now to do different resolutions for different monitors.
my laptop and desktops are completely different sizes.
That'll be fun.

It's interesting, I merged all layers to a single layer and then applied the brightness tweaks before splitting them in half.
After splitting them in half and applying to the screenshots, it looks like the top halves are darker than they were previously.


The only left to do is convert the whole movie with the animated function to mimic the Fingerprint trailers.
For the whole movie conversion, it won't be split in half like the wallpapers.
The wallpapers are separate parts of the same project.
Though for the movie conversion, I think I'll reduce it to 720p resolutions.

Thank you so much for all the help everyone!
David, hoping to see an update to your Fingerprint function for 2.6.
__________________
Win10 (x64) build 18362| GPU Caps Viewer 1.42.4.0
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
Intel Xeon X5660 @2.80GHz
Sparktank is offline   Reply With Quote
Old 14th June 2013, 15:49   #35  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,810
Quote:
Originally Posted by Sparktank View Post
It crashes instantly in VirtualDub with something about a "kernal" crash.
How long in frames is your clip?
wonkey_monkey is offline   Reply With Quote
Old 15th June 2013, 00:21   #36  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 903
Quote:
Originally Posted by davidhorman View Post
How long in frames is your clip?
@23.976, 244010 frames.
2:49:37.242 (H:MM:SS.sss) total run length of The Hobbit: An Unexpected Journey.
__________________
Win10 (x64) build 18362| GPU Caps Viewer 1.42.4.0
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
Intel Xeon X5660 @2.80GHz
Sparktank is offline   Reply With Quote
Old 15th June 2013, 16:19   #37  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,810
I was lazy and left resizing of the clip to AviSynth rather than doing it in-plugin. So it's probably AviSynth complaining about a) being given a 244010-pixel wide clip or b) being asked to resize said clip.
wonkey_monkey is offline   Reply With Quote
Old 15th June 2013, 23:15   #38  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,171
Probably running out of memory.

YV12 244010 x 480 clip is 167Mb per frame!

Resize works with that, but you cannot do much else.
IanB is offline   Reply With Quote
Old 16th June 2013, 01:00   #39  |  Link
Sparktank
47.952fps@71.928Hz
 
Sparktank's Avatar
 
Join Date: Mar 2011
Posts: 903
Oh, I misread what you meant.
I thought you were asking the total runtime of the movie in frames.

The frame width is 1920x800, cropped.

Here's what the basic script looks like before adding any of the fingerprint functions.

Code:
SetMemoryMax(1280)
SetMTMode(3,4)
DirectShowSource("L:\1080p (Remux)\The Hobbit.mkv").KillAudio()
SetMTMode(2)
Crop(0,140,0,-140)
SetMTMode(1)
Distributor()
Return(last)
__________________
Win10 (x64) build 18362| GPU Caps Viewer 1.42.4.0
NVIDIA GeForce GTX 1060 3GB (GP106) 3071MB/GDDR5 | (r435_95-4)
NTSC | DVD: R1 | BD: A
Intel Xeon X5660 @2.80GHz
Sparktank is offline   Reply With Quote
Old 16th June 2013, 04:12   #40  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,171
Where are people getting the crazy idea that a big SetMemoryMax is ever a good idea.

I have searched the forum numerous times looking for any fud and misinformational posts and I do not find any, all I find are the occasional post advising to turn it down. and lots of posts with people using insanely high values and having problems.

SetMemoryMax just sets the size of the Avisynth frame cache!

It does not control any other memory usage!

The frame cache only needs to be just large enough to hold the temporal requirements of the script. If a script has no temporal requirements, i.e. a frame that is required more than once in some part of the script then the cache is completely useless and may prevent some other memory usage from being able to malloc the memory that it needs to work.

A 1920x1080 YV12 video frame is ~3meg, as RGB32 it is 8meg, you can hold 64 such frames in 512meg. YV12 720x480 frames are only 0.5meg you can hold 1024 in 512 meg.

It takes some resources to manage the frame cache so doing a SetMemoryMax(2048) for a SD video and having 4000 odd buffers in play is just stupid and will actually slow the script processing down a little bit.

Advise :- SetMemoryMax, Turn it down!
IanB is offline   Reply With Quote
Reply

Tags
fingerprint, trailers, waveform

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 16:07.


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