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 29th August 2014, 09:42   #1  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Trim(), how much exactly?

Wiki says:

"Remember AviSynth starts counting at frame 0."

But then proceeds to say:

Trim(100,0) # delete the first 100 frames...

But wouldn't that be 101 deleted frames then?!

Reason I ask is because of following test:

Code:
Trim(70790, -50)

# FreezeFrame(70803, 70812, 70802)
FreezeFrame(13, 21, 12)
To figure out where the glitches are exactly, I first skipped 70790 frames (or 70791? is the point). I then subtracted 70790 from the FreeFrame start, for the test.

So, should I just add 70790 again to the 13 (70803); or, assuming Trim(70790, -50) did trim 70901 frames, start at 70804?

This process will take me ca. 70 hours, so I better get it right. :P)
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Old 29th August 2014, 10:53   #2  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,496
trim(100,0) means the trimmed clip will start at frame 100 (the parameter doesn't mean "delete up to and including frame 100", but "start at frame 100"), skipping frames 0-99 (which is a total of 100 frames).

So frame 13 in your trimmed clip will be frame 70790+13=70803 in your original clip.

showframenumber can be of great help in these circumstances (you could apply before and after the trim to see which numbers correspond).
__________________
My AviSynth filters / I'm the Doctor

Last edited by wonkey_monkey; 29th August 2014 at 11:00.
wonkey_monkey is offline   Reply With Quote
Old 29th August 2014, 11:29   #3  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Quote:
Originally Posted by davidhorman View Post
trim(100,0) means the trimmed clip will start at frame 100 (the parameter doesn't mean "delete up to and including frame 100", but "start at frame 100"), skipping frames 0-99 (which is a total of 100 frames).

So frame 13 in your trimmed clip will be frame 70790+13=70803 in your original clip.

showframenumber can be of great help in these circumstances (you could apply before and after the trim to see which numbers correspond).
Ah yes, thx! I got my logic wires crossed on that, it would seem.

FAUX EDIT: Already figured out ShowFrameNumber(), right after I posted this. Turns out ShowFrameNumber() shows the actual frame number (sans the trim), when appended to the FFVideoSource line (which makes sense, of course). This proved to be very useful, as it just showed 70803 in my test clip, so turns out I had no need to calculate, after all.
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Old 30th August 2014, 16:01   #4  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
On the matter of trimming, could Trim() be used to splice two or more sources? (Cut on I-Frames boundaries, of course). That way, instead of doing 1 huge >200 hour encoding session, I might chop it up into several (lossless) parts, and spice em all together later on.

Or does AviSynth only alllow 1 video source?

Thanks.
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Old 30th August 2014, 16:12   #5  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
Avisynth supports multiple source filter invocations. You can use Trim() with the ++ operator to splice clips. Refer to the Avisynth documentation.
videoh is offline   Reply With Quote
Old 30th August 2014, 16:12   #6  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
Quote:
Originally Posted by asarian View Post
On the matter of trimming, could Trim() be used to splice two or more sources? (Cut on I-Frames boundaries, of course). That way, instead of doing 1 huge >200 hour encoding session, I might chop it up into several (lossless) parts, and spice em all together later on.

Or does AviSynth only alllow 1 video source?

Thanks.
if your clips are in the same format (same resolution, same colorspace, same framerate) you can just use "+" to join them together
Code:
a1=clip1
a2=clip2
a3=clip3
....
return a1+a2+a3+....
the upper script will get all the clips together again
feisty2 is offline   Reply With Quote
Old 30th August 2014, 16:24   #7  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Quote:
Originally Posted by feisty2 View Post
if your clips are in the same format (same resolution, same colorspace, same framerate) you can just use "+" to join them together
Code:
a1=clip1
a2=clip2
a3=clip3
....
return a1+a2+a3+....
the upper script will get all the clips together again

Now, that is good to know. Thx.

In reality, however, I would probably want to encode the parts with a certain overlap (like for things like MCTemporalDenoise(), so as not to see the sudden transition, kinda like how threading works with overlap). And then use Trim() to splice em together.

So, if all parts had like 100 frames (including overlap), like:

return a1.Trim(0, 90)+a2.Trim(10, 90)+a3.Trim(10, 90)...

From what you're saying, it looks like that will be possible. Thx again.
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Old 30th August 2014, 16:34   #8  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
Quote:
Originally Posted by asarian View Post
Now, that is good to know. Thx.

In reality, however, I would probably want to encode the parts with a certain overlap (like for things like MCTemporalDenoise(), so as not to see the sudden transition, kinda like how threading works with overlap). And then use Trim() to splice em together.

So, if all parts had like 100 frames (including overlap), like:

return a1.Trim(0, 90)+a2.Trim(10, 90)+a3.Trim(10, 90)...

From what you're saying, it looks like that will be possible. Thx again.
the trimming should be based on the scene change frames, a scene change frame is where the current motion compensate terminated and a new compensate incepts

edit: if you split your clip at scene change frames, you don't need to overlap at all, and splitting at scene change frames is how mvtools2 works internally as well, there're 2 parameters "thscd1", "thscd2" in mvtools2 which control the detection of scene change stuff

Last edited by feisty2; 30th August 2014 at 16:49.
feisty2 is offline   Reply With Quote
Old 30th August 2014, 17:07   #9  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Quote:
Originally Posted by feisty2 View Post
the trimming should be based on the scene change frames, a scene change frame is where the current motion compensate terminated and a new compensate incepts

edit: if you split your clip at scene change frames, you don't need to overlap at all, and splitting at scene change frames is how mvtools2 works internally as well, there're 2 parameters "thscd1", "thscd2" in mvtools2 which control the detection of scene change stuff
Thx. That feels like an excellent idea!
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Old 30th August 2014, 21:36   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Perhaps of interest:

Trim Splice from Multiple source clips: http://forum.doom9.org/showthread.php?t=162446

Trim Splice from single source clip: http://forum.doom9.org/showthread.ph...59#post1683559

Both with audio fade at splices (default 1ms) to avoid clicks and cracks in audio.
__________________
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 30th August 2014, 21:43   #11  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Quote:
Originally Posted by StainlessS View Post
Perhaps of interest:

Trim Splice from Multiple source clips: http://forum.doom9.org/showthread.php?t=162446

Trim Splice from single source clip: http://forum.doom9.org/showthread.ph...59#post1683559

Both with audio fade at splices (default 1ms) to avoid clicks and cracks in audio.
Thanks! Those look great! For now I'm still concentrating on splitting up an x264 stream into several (lossless) parts, on safe key-frames, so as to re-encode them individually. These splicing tools will definitely help re-combining them again.
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Reply

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 21:17.


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