Avisynth: Trim and ConditionalFilter?
I found this example on an avisynth site
conditionalfilter(last,last,last.trim(1,0),"YDiffe renceToNext()",">","10", show=true) It looks like the basis for solving a problem I have involving scene changes, but I always get the error saying "Invalid arguments to function Trim". As this is copied and pasted exactly from the original and I have the latest avisynth shouldn`t this be working? It is the trim part causing the problem but I`m unsure why. What I`m trying to do is compare the difference between two frames and if a difference is found replace the current frame with a previous one (a possible solution to a problem I have mentioned in a seperate post). Any ideas as to why this is not working? I`m new to the more complex side of avisynth like this, and can`t seem to figure out whats doing it. If I remove last.trim(1,0) and change it for something I know is okay like video (the variable holding my video footage) the error message changes to saying Conditional Filter has invalid arguments :( |
Re: Trim and ConditionalFilter
Quote:
Code:
clip1=last |
It still gives the same error :(
"Invalid arguments to function Trim" is the error, but I don`t see why although if I cpy and paste scriptclip examples they also give me a similar argument. Is there a straightforward way, not needing to use trim that could check between current and previous frames? Thanks. |
Quote:
You can see how we use it in optimal filter (see sticky post in optimal script section of the forum). |
Code:
tr=Trim(last,1,0) ... does NOT! only detect scenechanges! It also lets get the trimmed stream active if a LUMA change above 10 will happen and thats also very often the case in scenes including much motion! That Workout above even if it would work the way YOU want it, it will mess up your video totally IMHO. Means that your final stream will result in fast motion scenes in a freaky jerkyness, A real scenechange detector, but its purpose was to write the Scenechanges into a file "Scenechanges.txt"! I did that one some weeks ago as part for a scene pattern detector out of a fieldblended stream. Do take what you need: Code:
avisource("Video.avi",false) |
It`s weird but neither this example nor the use of scriptclip in the optimal scripts section is working at all, as with the conditional filter I get an error about invalid arguments but it should be working fine :(
I`ve been trying to get this working for two days now and it seems avisynth is being temperamental and just won`t let me. I shall try again after work, thanks for all the help - it has shown me what should work, it seems to be something stopping it working but if I can find out what it looks like it would work. |
Try to do a script with ONLY a trim line, just to see if the isn't an issue with all you are doing before the trim in the script.
|
Show us your ACTUAL FULL script, maybe you assignet already your videodata to a variable so trim has to be assignet different
|
I wrote a basic script. This doesn`t work:
film=avisource("C:\AVI\video_data\video.avi") tr=Trim(last,1,0) return(tr) But if I take out the film= so it reads avisource("C:\AVI\video_data\video.avi") tr=Trim(last,1,0) return(tr) It works but I need to be able to use an assigned name, like film, with trim as the script uses more than one video. I`m new to complex avisynth scripting so forgive any dumb comments but it appears that what is happening is that "last" works with just one video input like avisource("x.avi") rather than x=avisource("x.avi")? In that case would it be possible to somehow feed trim the name of a video file to connect with the value of last, something like tr=trim(last(video),1,0) ? I did try this but as far as I know last can`t have a parameter. Even if it is not, I do want to say thanks for all the help (and quick replies too) - it is DEFINITELY appreciated - thanks :) I forgot to mention I upgraded from avisynth 2.55 to latest alpha in case that helped but didn`t have a different effect. |
Quote:
You have to use "tr = trim(film,1,0)" :!: Last is instantiated only if the result of a command is not already set to a variable name. |
So it isn`t possible with trim to return the most recent frame to use in comparisons?
|
If you just load a movie as global like
avisource(xxxxx.xx) then the that actual frameserved peace of stream will be "last". film=avisource(xxxxx.xx) Means you assign the stream to a variable and so you can assign in a specific way commands to specific variables containing streams. Quote:
film=avisource(xxxxx.xx) tr=trim(film,1,0) return tr Means only your "film" stream will be treaten. |
Quote:
Is that correct? |
Quote:
|
Exact!
So "film" is one frame ahead of "tr" (if its wanted). Now you can perform comparings or so of these two streams. OR finally you could let become "tr" as final single video out: film=avisource(xxxxx.xx) tr=trim(film,1,0) return tr # ------- "tr" becomes "last" or do let a filter of your choice let become "tr"as final single video out: film=avisource(xxxxx.xx) tr=trim(film,1,0) undot(tr) # -------- "tr" becomes "last"! Bicubicresize(352,480) # from here on as usual avisynth uses "last" |
A nice tip for comparings!
v= Avisource("MainVideo.avi") a= v.deen().subtitle("Preview of Deen()",10,10) b= v.TemporalSoften().subtitle("Preview of TemporalSoften()",10,10) interleave(a,b) The interleave command does order the frames of "a" and "b" one by one. Means: a_frame1 ---- b_frame1 ---- a_frame2 ---- b_frame2 ---- a_frame3 ---- b_frame3 ... etc. So you can use that procedure to just use your "frame forward/backward" keys of Vdub for instance to compare both filterings immediately. Its like in Photoshop layer on/off. :) So do forget that "StackHorizontal()" Method which is often used for compare side by side as with the method above your eyes will see directly whats different. Think about it as using it in Moviestacker Muaddib ;-) |
Quote:
I mean the "tr" is one frame ahead of "film"? :roll: If we "delete" the first frame of "tr" with "trim", them (thinking film as the source) "film" will be at frame 0 while "tr" will be at frame 1... :?: Quote:
|
Ähhhmmmm .... :banghead:
Yep, ... the one which is cuttet will be the one frame ahead. :) |
I`ve just got on my pc and seen all these replies - brilliant :D
I`m going to read these fully later and work through what`s come up in them, I`ve read through briefly and seen it noticed one film is a frame ahead of the other. That is right though, the idea is that the difference in motion between two frames adds to the 3D effect and you get proper 3D. Works great but then each scene change has a bright red flash where you see one frame in red from before - hence my trying to get rid of excess red in that frame, or replace it with unchanged (non red) version :) |
Got the script replacing red flashes (scene changes) with the help of all of your suggestions, came up with the following but it still leaves the audio short:
# video is the 3D version of the film lst=Trim(video,1,0) x=ConditionalFilter(lst, video, lst.trim(1,0), "VDifferenceToNext()", ">", "16", true) x=Tweak(x, sat=2,bright=4,cont=2) audio=SSRC(audio, 48000) film=audiodub(x, audio) film=AssumeFPS(film, 25.000, true) return(film) Is this because the video is being trimmed? As I understood it this script extract should replace a frame with another rather than delete a frame entirely? Thanks again for all the help, I couldn`t have got this far without all the help I`ve had - and it`s made me realise avisynth is even more amazing than I thought :!: |
Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.