View Full Version : Trim Not Working


cg2916
19th August 2012, 03:45
Whenever I use Trim, it doesn't give me any errors, but it doesn't trim out ANY of the video clip. How do I fix this?

AzraelNewtype
19th August 2012, 04:11
Yeah.......... you're going to have to post a sample script before getting an answer.

StainlessS
19th August 2012, 04:20
@AzraelNewtype, dont be cruel, let the lad post his script, we all want to see it. :)

EDIT: No seriously cg2916, post the script. Anybody can make mistakes
or mis-assumptions, and I guarantee it will not be terminal.

Didée
19th August 2012, 05:27
With utmost probability, it's a case of one of the most-common misunderstandings: inherent last, and re-assignment of variables.

WRONG:
vid = avisource(...)

vid.trim(123,4567)

return(vid) (The 2nd line performs "trim()", and / but, the result is stored in the inherent "last" variable. The clip variable "vid" is not changed. The unchanged "vid" is returned.)


Correct: variant #1:
vid = avisource(...)
vid.trim(123,4567)
return(last)
(The 2nd line performs "trim()", and stores the result in the inherent "last" variable. The content of "last" is returned.)


Correct: variant #2:
vid = avisource(...)
vid = vid.trim(123,4567)
return(vid)
(The 2nd line performs "trim()", and stores the result in the clip variable "vid" again. The updated "vid" is returned.)


Correct: variant #3:
avisource(...)
trim(123,4567)
return(last)
(Simple chain using only inherent "last", without explicit clip variables.)

cg2916
20th August 2012, 23:18
video = AviSource("C:\Users\Patricia\Videos\originaldvdrip.avi")

Trim(video,100,0)
Amplify(video, 4)
deVCR(video, 30)
Sharpen(0.8)
ConvertToYUY2()
FixLuminance(50, 1000)
ConvertToYV12()
MDeblock()

function DetectVCRLines(clip c,int threshold)
{
spacial_data = GeneralConvolution(ConvertToRGB(c),0,"0 -1 0 0 2 0 0 -1 0")
bar_data = ConvertToRGB(BilinearResize(spacial_data,16,c.height))
st_data = Overlay(bar_data,Trim(bar_data,1,0),mode = "subtract")
st_data2 = Greyscale(Levels(st_data,threshold,10.0,threshold+1,0,255,coring = false))
st_data3 = Greyscale(Levels(st_data2,127,10.0,128,0,255,coring = false))
st_data4 = Overlay(st_data3,st_data3,y = -1, mode = "add")
return PointResize(st_data4,c.width,c.height)
}

function deVCR(clip c,int threshold)
{
mybars = DetectVCRLines(c,threshold)
return Overlay(c,Trim(c,1,0), mask = mybars,greymask = true)
}

Groucho2004
20th August 2012, 23:37
Did you even bother to read Didée's post?

IanB
20th August 2012, 23:39
video = AviSource("C:\Users\Patricia\Videos\originaldvdrip.avi")

Trim(video,100,0)
Amplify(video, 4)
deVCR(video, 30)
Sharpen(0.8)
ConvertToYUY2()
FixLuminance(50, 1000)
ConvertToYV12()
MDeblock()

........

Guest
21st August 2012, 01:10
Let's be kind and actually give him a solution:

video = AviSource("C:\Users\Patricia\Videos\originaldvdrip.avi")

Trim(video,100,0)
Amplify(4)
deVCR(30)
Sharpen(0.8)
ConvertToYUY2()
FixLuminance(50, 1000)
ConvertToYV12()
MDeblock()

cg2916
21st August 2012, 01:13
Let's be kind and actually give him a solution:

video = AviSource("C:\Users\Patricia\Videos\originaldvdrip.avi")

Trim(video,100,0)
Amplify(4)
deVCR(30)
Sharpen(0.8)
ConvertToYUY2()
FixLuminance(50, 1000)
ConvertToYV12()
MDeblock()


Thank you, but the trimming still doesn't work.

Didée
21st August 2012, 01:28
That script looks like it must work. Are you sure you got the trim() logic right? Trim(100,0) means "discard frames 0-99, keep frames 100 to [EndOfVideo]".

(Sorry if it's a dumb question, but since I don't see any problem in neuron's script, I have to ask that.)

Guest
21st August 2012, 02:23
Yes, indeed, please tell us what frames you are trying to delete and which you try to retain.

cg2916
21st August 2012, 14:13
That script looks like it must work. Are you sure you got the trim() logic right? Trim(100,0) means "discard frames 0-99, keep frames 100 to [EndOfVideo]".

(Sorry if it's a dumb question, but since I don't see any problem in neuron's script, I have to ask that.)

I've got it right. It's not trimming the first 100 frames. It's not trimming anything.

Guest
21st August 2012, 14:17
Try removing all these lines and tell us the result:

Amplify(4)
deVCR(30)
Sharpen(0.8)
ConvertToYUY2()
FixLuminance(50, 1000)
ConvertToYV12()
MDeblock()

Your script will be just:

video = AviSource("C:\Users\Patricia\Videos\originaldvdrip.avi")
Trim(video,100,0)

You can also try:

AviSource("C:\Users\Patricia\Videos\originaldvdrip.avi")
Trim(100,0)

Didée
21st August 2012, 15:15
Wild guess: If the very-last line (not posted here) is again "return(video)", well, then ...

librarian
21st August 2012, 15:16
Someone who knows "arcane stuff" like Fixluminance (only mentioned but non detailed in the docs) and uses a not often mentioned Mdeblock can't use Trim?
Copy & paste ok but only finding the original script requires experience...

Guest
21st August 2012, 15:33
Wild guess: If the very-last line (not posted here) is again "return(video)", well, then ... That's why I was careful to use the word "just":

Your script will be just:

video = AviSource("C:\Users\Patricia\Videos\originaldvdrip.avi")
Trim(video,100,0)

I'm thinking your wild guess must be correct.

cg2916
21st August 2012, 23:23
Got it! Removing the video = AviSource(...) and taking out the video arguments in the functions worked! Thank you!

Guest
21st August 2012, 23:36
Sometimes you will need to retain that video= syntax, such as when dubbing.

video=AVISource()
audio=NicAC3Source()
AudioDub(video,audio)

The key is understanding the stuff that Didee posted about implicit last etc.

Groucho2004
22nd August 2012, 09:27
The key is understanding the stuff that Didee posted about implicit last etc.
Or just reading the documentation.
However, be aware that reading the documentation can lead to understanding how Avisynth works!