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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th February 2012, 16:18   #101  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 263
You probably could have just used:

SelectEvery(clip, 999999, 2, 3, 5, 7, 9, 13)

If your source has more than 999999 frames, then increase the number to suit. It just needs to be bigger than the total number of frames presented. (I wonder if there's a limit on how many frames SelectEvery can handle?)

...but having a separate function for it might be easier for people. And it would be interesting to see which version performs better.

Could you provide the source code, too? This would be a good training example for folks starting out on coding their own plug-ins, I think: A nice simple objective, which lets you focus on one aspect of what a typical plug-in needs to do.

Thanks!
pbristow is offline   Reply With Quote
Old 26th February 2012, 17:35   #102  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by davidhorman View Post
Code:
simpleselect(clip, f1 [,f2...,fn])
Return only frames f1, f2,...,fn of the source clip
How does it treat the audio?
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 27th February 2012, 00:35   #103  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,496
Quote:
Originally Posted by pbristow View Post
You probably could have just used:

SelectEvery(clip, 999999, 2, 3, 5, 7, 9, 13)
Argh, you know what? I actually tried that, and I thought it wasn't working as expected - but that was because I was stacking the result with the original clip, so it appeared that it was returning a clip with the selected frames and then holding the last frame .

Source is here (fixed), but I don't know useful it will be, it really was cobbled together - I still only have a vague grasp of how filters come together, I only know just enough to pummel the simplesamples into doing what I want.

Quote:
Originally Posted by Gavino
How does it treat the audio?
Probably quite badly!

David

Last edited by wonkey_monkey; 27th February 2012 at 17:48.
wonkey_monkey is offline   Reply With Quote
Old 27th February 2012, 03:36   #104  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
David, source; 404.

If you want to handle audio, you need a 'GetAudio' member fn, presume you have not got one.
(otherwise, will get full length audio from source clip)

If you dont want any audio in output clip, set 1st 2 or 3 of below, to 0 in constructor.
Code:
  vi.audio_samples_per_second=0;   // 0 means no audio, type int
  vi.num_audio_samples=0;            // changed as of 2.5, type __int64
  vi.nchannels=0;                         // as of 2.5, type int
EDIT: Found it, here is David's link to source (used "SimpleSample.cpp" by mistake):-
http://horman.net/simpleselect.cpp
Very succinct, looks ok to me.

EDIT: May want to add below to constructor
Code:
    frames=(int*)malloc(vi.num_frames*sizeof(int));
    if(frames==NULL)
        env->ThrowError("SimpleSelect: Cannot allocate memory");
__________________
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; 27th February 2012 at 14:41.
StainlessS is offline   Reply With Quote
Old 23rd March 2012, 01:29   #105  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
FrameSelect() v1.0, NEW Plugin for Avisynth v2.5+ by StainlessS.

FrameSelect() is a simple plugin to select individual frames from a clip.

Can select frames numbers by direct arguments to filter, or in a string, or in a command file.

Video:- Planar, YUY2, RGB32, RGB24.

Audio:- Returns NO AUDIO (Does not really make sense for individual frames).

EDIT: For frame range and audio support with fade in/out see trim/splice plugin Prune().
http://forum.doom9.org/showthread.php?t=162446
EDIT: For frame range replacement see ClipClop().
http://forum.doom9.org/showthread.php?t=162266


FrameSelect(Clip, int F1, ... , int Fn, string 'SCmd',string 'Cmd', bool 'Show', bool 'Ver')

http://forum.doom9.org/showthread.php?t=164497

Partly inspired by DavidHorman's SimpleSelect() 2 posts earlier. (Thankyou David).
__________________
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; 23rd March 2012 at 16:18.
StainlessS is offline   Reply With Quote
Old 23rd March 2012, 12:34   #106  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 263
Quote:
Originally Posted by StainlessS View Post
FrameSelect() v1.0, NEW Plugin for Avisynth v2.5+ by StainlessS.

FrameSelect() is a simple plugin to select individual frames from a clip.

Can select frames numbers by direct arguments to filter, or in a string, or in a command file.
Interesting... With the command string & file options, do you plan to allow ranges (e.g. "1; 15-18; 32-399; 501")? That would be a very nice way of setting up EDLs (Edit Decision Lists). The same format could then be used as efficient output for functions that detect various things happening in the video.

A nice companion function would then be something that, rather than just selecting or ignoring frames from a single source, would actually switch between two sources - i.e. frames listed are taken from source A, but the rest are instead taken from source B. People who are writing functions to detect and fix particular symptoms in video then wouldn't have to worry about implementing their own switching logic: Just have the detecting filter output an EDL listing the frames that need "fixing", then run it with a script such as:

Code:
  EDL = Q:\project\list_of_bad_frames.txt
  FindTheBadness(OriginalVideo, threshold=99, output=EDL)
  FixedVideo = FixTheBadness(OriginalVideo)
  SelectAlternative(FixedVideo, OriginalVideo, commandfile=EDL)
Or even run FindTheBadness just once, and re-use the same EDL many times as they develop and fine-tune the way FixTheBadness works.
pbristow is offline   Reply With Quote
Old 23rd March 2012, 12:45   #107  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 263
[SLAPS FOREHEAD] Ignore me, I missed the edit where you'd linked to Prune() and ClipClop(). You're clearly way ahead of me.
pbristow is offline   Reply With Quote
Old 25th March 2012, 03:50   #108  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
ClipClop() v1.10, Range/Frame Replacement Plugin for Avisynth v2.5+ by StainlessS.

New Version v1.10, Major improvement.

http://forum.doom9.org/showthread.php?t=162266

Planar, YUY2, RGB32, RGB24.

Does NOT affect Audio (as source clip).

Code:
ClipClop() v1.10, Range/Frame Replacement Plugin for Avisynth v2.5+ by StainlessS.

Planar, YUY2, RGB32, RGB24.

Does NOT affect Audio (as source clip).

Clipclop is a simple plugin to replace ranges in a source clip with the same range, from a replacement clip.
Supports up to 255 replacement clips, with unlimited number of replacements into output clip.


If you wanted to do 1000 single frame replacements in script, that would require 3 trims and 2 splices for each
replaced frame, ie 3000 trims and 2000 splices. This would involve 5000 'zero cost' filters which together will
cost a little more than zero. With ClipClop(), this is reduced to 1 single filter with an overhead of approx
1 trim or splice filter. There is a small overhead setting up the filter (before the very 1st frame is fetched)
while parsing the file/string commands, but then parsing and setting up 5000 trim/splice filters in a script
would not be without cost either. Clipclop can parse in the region of 40000 commands (from file) in about 1 second
[guessed, based on timing the sister plugin Prune(), a trim/splice plugin].

v1.10, Implements 'Nickname's, Pseudonyms for the replacement clips, ie instead of '17 100,200' you could use eg 'dn 100,200',
in this case it might be to replace frames 100 to 200 of the source clip with the same frames of a denoised clip (clip 17). 
OR, 'cp 345' to replace frame 345 with a clip where frame n was copied from frame n-1 of the source clip, ie CopyFromPrevious
[this could be generated via 'SelectEvery(1,-1)', or 'CopyFromNext' clip by 'SelectEvery(1,1)]. 
Supports Nicknames of up to 31 characters in length so you could use eg 'PredictFromPrevious 1234', or 'FlippedVertical 666,999'.
Nicknames allow you to think in terms of functionality rather than to keep looking up which clip index holds a modified clip
and you could actually write your command file/string before you even know how many clips you need, what clip index they will be,
or even how you will actually create/process the clip.

Once you've tried ClipClop(), you will wonder why you spent all those years doing it the hard way.
(Repeat after me, "I dooo believe in Fairies!".)
__________________
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 26th March 2012, 19:27   #109  |  Link
Hakker
Registered User
 
Join Date: Feb 2007
Posts: 1
This place could use a place where authors can host their files. sometimes you need to search a while to get a certain plugin due to host of it being dead and all.
Hakker is offline   Reply With Quote
Old 23rd April 2012, 01:09   #110  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
New Script filter.

MatchFrames v1.02 - 23 April 2012

Code:
Function MatchFrames(clip c, clip f, bool "Show", Float "Thresh",Float "Thresh2",string "FileName",string "LogFile")
# MatchFrames v1.02, by StainlessS:
# Find And return frames in c clip that are best matched to frames in f clip.
# Requires YV12, as uses LumaDifference(). Null Audio returned.
# ##########
# Args:
# c       = clip, Source clip.
# f       = clip, Consisting of frames that you wish to find in the c clip.
# Show    = bool[true], Returns both find and found frames using StackHorizontal.
# Thresh  = float[0.0 == Search for best match], Threshold for declaring match.
# Thresh2 = float[0.0 == NOT time ordered],  If (Thresh < Thresh2) Then clip f is time ordered (in c).
#           This arg can significantly cut down on the time taken to search for frames.
#           Assuming time ordered f clip (Thresh < Thresh2),
#               Where:- 
#               A match found where diff of find to found frames <= Thresh,
#                    Next search will start from found frame + 1.
#               Else if diff of find to BEST found frame < Thresh2,
#                    Next search will start from BEST found frame + 1.
#               Else
#                    Next search will start from current start position.
#               End if                    
#                
# FileName= string["MatchFramesCmd.txt"], Output Frames command file (For FrameSelect plugin).
# LogFile = string["MatchFrames.Log"], Output Log file.
# ##########
A mod of Gavino's FindFrame()

Advantages:-

Deals with a clip of frames to find rather than a single frame.
Can find best match or 1st match below or equal to a threshold.
Float Threshold.
Can show StackHorizontal required 'find' frame alongside source clip 'found' frames.
Can output a command file consisting of frame numbers found.
Command file can be used with FrameSelect() Plugin to select all found frames (useful if viewing StackHorizontal frames without 2nd SLOW run for extraction).
Outputs LogFile
Can cut down on search times if clip f is known to be time ordered (in c).

Find it here:
http://forum.doom9.org/showthread.php?t=164766
__________________
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; 23rd April 2012 at 01:13.
StainlessS is offline   Reply With Quote
Old 9th July 2012, 05:37   #111  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
New Avisynth filter
taverage 0.1 by jmac698
Jul 8, 2012

A filter to average all frames, pixel-by-pixel. YUV formats only. Designed for Avisynth 2.58.
Usage: taverage(clip clip)

Source is GPL

Note, it's very slow.

http://www.sendspace.com/filegroup/9...%2BWcMacRzuyCQ
jmac698 is offline   Reply With Quote
Old 11th July 2012, 04:24   #112  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
New Avisynth plugin
findpos 0.2 by jmac698
Jul 11, 2012

A filter to find pixels on each line. YUV only. Avisynth 2.58+
Usage: findpos(clip clip, int x1, int x2, int thresh)

Search from x1 to x2 on each line for a pixel >=thresh, return a clip where luma of each line is the position found.
If not found, luma will be x2.

defaults:
x1 0
x2 7
thresh 22

http://www.sendspace.com/file/x5abs3

Version History

0.2: Release build. Ensure you have the vc2008 runtime installed.

Last edited by jmac698; 12th July 2012 at 10:42.
jmac698 is offline   Reply With Quote
Old 11th July 2012, 11:25   #113  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
New Avisynth filter
dejitter 0.3 by jmac698
Jul 11, 2012

A filter to resize each line of the source by a different amount. YUV only. Avisynth 2.58+
Usage: dejitter(clip src, clip offsets)

For each line, read the luma of the first two pixels of offsets. Call these x1 and x2. Resize the source
from pixels x1 to x2 inclusive to be the full width of the source.
Uses bilinear filtering.

http://www.sendspace.com/file/8imj3k

0.3: Made release build. Make sure to install the vc2008 runtime as well.
0.2: fix problem with x1
0.1: first release

Last edited by jmac698; 12th July 2012 at 00:43. Reason: Updated
jmac698 is offline   Reply With Quote
Old 11th July 2012, 12:49   #114  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
New Avisynth script
TBC 0.61 by jmac698
Jul 11, 2012

A script to resize each line of the source by a different amount, by searching for black borders. YUV only. Avisynth 2.58+
Usage: see tbc.avs demo
Requirements: dejitter 0.2, findpos 0.1 (included)

0.6: first plugin version

http://www.sendspace.com/file/s78pp4

Installation note:
Please extract the included plugins and place into your plugins directory.
jitter03.zip -> jitter.dll -> plugins\jitter.dll
findpos02.zip -> findpos.dll -> plugins\findpos.dll
The VC2008 runtime is required. Download at:
http://www.microsoft.com/en-us/downl...s.aspx?id=5582

Version History

0.61: Included updated plugins.

Last edited by jmac698; 12th July 2012 at 10:41.
jmac698 is offline   Reply With Quote
Old 12th July 2012, 10:38   #115  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
New Avisynth runtime plugin
jcorr 0.3 by jmac698
Jul 25, 2012

A plugin to calculate the correlation between two frames. YV12 only. Avisynth 2.58+

Usage: jcorr(clip clip1, clip clip2)#returns float, can be used as runtime value

http://www.sendspace.com/file/5ke3a7

Note:
Do not confuse with corr2d, at http://avisynth.org/vcmohan/Corr2D/Corr2D.html ,
which calculates many correlations per frame to let you find the movement between frames in a panning scene.

Version History

0.3
-Fixed small numerical inaccuracy
-Made new test file to find inaccuracy
-Changed to a faster algorithm
-Static, SSE build
July 25

0.2
Fixed bug where one of the calculations used a chroma plane.
Updated demo script with better tests.
July 12

0.1
first release.

Last edited by jmac698; 25th July 2012 at 14:33.
jmac698 is offline   Reply With Quote
Old 12th July 2012, 12:46   #116  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
New Avisynth plugin
corrbyline 0.1 by jmac698
Jul 12, 2012

A plugin to calculate the correlation between two frames, a line at a time. YUV only. Avisynth 2.58+

Usage: corrbyline(clip clip1, clip clip2)
Returns a clip of the same properties and the correlation as the luma per line, *255, if positive, 0 otherwise.

Note: to be published later

Last edited by jmac698; 13th July 2012 at 09:55.
jmac698 is offline   Reply With Quote
Old 12th July 2012, 19:04   #117  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
You gave both plugins the same name?
Wilbert is offline   Reply With Quote
Old 12th July 2012, 19:14   #118  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
oops typo, and in fact don't have time to post it...
jmac698 is offline   Reply With Quote
Old 13th July 2012, 09:58   #119  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
New Avisynth plugin
slicer 0.3 by jmac698
Jul 16, 2012

A plugin to extract raw VBI data. YV12 only. Avisynth 2.58+
Planar only.

Usage: slicer(clip clip, int line, int x, int width, int bits, int order, int slicelevel, int n)#returns int, can be used as runtime value

clip - a video with some white lines in it, such as EIA608, Teletext, Timecode, etc.
line - the line to extract
x - the starting x coordinate to look for the code. Should set to the mid-point of the first bit.
width - the width of the bits
bits - the number of bits (<32)
order - 0 means lsb first, 1 means msb first
slicelevel - anything above this is a "1". In an ideal video, this would be set to 126.
n - optional frame number to use, otherwise current_frame

http://www.sendspace.com/file/b0798i

Note:
There is also a similar plugin, DumpPixelValues
http://www.theneitherworld.com/mcpoo...xelValues.html

Version History

0.3
Changed width to float, as long codes need more precision.
Jul 16

0.2
New demo with a real code. Updated docs.
Jul 16

0.1
first release.
Jul 13

Last edited by jmac698; 17th July 2012 at 01:38.
jmac698 is offline   Reply With Quote
Old 13th July 2012, 21:40   #120  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
New Avisynth filter
addcode 0.2
Jul 16, 2012 by jmac

An Avisynth plugin to add codes (like timecodes) as white lines to a video.

Usage:
addcode(clip clip, int line, int x, float width, int height, int bits, int order, int luma0, int luma1, int word)

clip - video to add code to
line - line to start code on
x - starting position of code
width - width of each bit
height - height of each bit
bits - number of bits to draw
order - 0 means draw lsb first, 1 means msb first
luma0 - luma to draw for 0 bit
luma1 - luma to draw for 1 bit
word - a number representing the bits to draw

This will only draw the bits as a block, overwriting the specified area of the video. Some parts of the video may still show at the sides. If you want a completely black background, either make sure the bits take the full width of the video, or draw a black line by using a full width code of 0 bits first. You can also create settings to draw arbitrary white or black lines anywhere on the video. It's even possible to turn this into a plot function with foreground and background pens. It could plot single pixels in YV12 which is normally quite difficult. It could also draw checkerboards.

To add a timecode, use something like this in a scriptclip:

addcode(last,last.height-4,0,last.width/18,2,18,0,16,235,current_frame)#good for at least 145 minutes
http://www.sendspace.com/file/udsu6h

Version History

0.2
Changed width to float, added timecode example and drawing rectangles to demo.
Jul 16

0.1
First release. There is very little checking, please use reasonable values.
The x, width, and height should not exceed the video size
Jul 13

Last edited by jmac698; 17th July 2012 at 02:40.
jmac698 is offline   Reply With Quote
Reply


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 14:15.


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