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

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 8th January 2011, 10:46   #201  |  Link
bidmead
Registered User
 
Join Date: Jul 2007
Posts: 35
A Trivial Mod?

I'm wondering if anyone here (Zarxrax?) knows the core AvsP code well enough to make the following mod. It may well be fairly trivial.

Instead of the Trim Editor writing out a cut as:

Code:
Trim(w,x) ++ Trim(y,z)
...could it be set (perhaps a user option switch) to do:

Code:
Dissolve(Trim(w,x), Trim(y,z), 0)
At a minimum we might have a discussion here about the feasibility and/or value of this mod.

--
Chris
bidmead is offline  
Old 8th January 2011, 12:03   #202  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,433
Quote:
Originally Posted by bidmead View Post
...could it be set (perhaps a user option switch) to do:

Code:
Dissolve(Trim(w,x), Trim(y,z), 0)
Possibly a useful feature, but not with overlap=0 in the Dissolve, which would make it exactly the same as the original Splice.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline  
Old 8th January 2011, 14:17   #203  |  Link
bidmead
Registered User
 
Join Date: Jul 2007
Posts: 35
Well spotted, Gavino... :-)

Yes, that was rather the point.

The function is identical to a splice, but easily editable into a dissolve.

--
Chris
bidmead is offline  
Old 8th January 2011, 15:16   #204  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,433
Ah, sorry Chris, I wondered about that after I posted.

But if the feature is to be an option, the overlap parameter should be chosen by the user and inserted by AvsP, not edited manually afterwards.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline  
Old 8th January 2011, 17:05   #205  |  Link
bidmead
Registered User
 
Join Date: Jul 2007
Posts: 35
Well, whatever. This might be the place for a slider variable, but that's not the way I tend to work.

When I first set a splice I know the exact amount I want to cut, but not what the best dissolve overlap, if any, might be. I want to play the cut first, and then decide.

So after the Trim Editor has delivered, say:

Code:
Trim(0, 700) ++ Trim(1112, 5649)
I'll convert this to:

Code:
Dissolve(Trim(0, 700) ,  Trim(1112, 5649), 0)
(qwerpoi wrote me a macro to do this years ago...)

...then add my own inspection Trim around the splice using another macro:

Code:
Trim(501,901) #Inspection Trim
... so that I can encode and run that section to see how it looks and sounds. (The system I use doesn't have enough processor power to play an Avisynth dissolve in real-time).

This tells me enough to know whether to leave this as a cut or what depth of dissolve is going to work best, and I just edit the overlap parameter by hand. Then optionally re-encode the inspection selection for a final check before removing the inspection trim and moving on to the next splice.

So I'm generally going to start with 0 as the overlap parameter so that I can see what a straight cut is going to look and sound like ("Never dissolve when you can cut..."). Not much point, then, in adding more flourishes to the GUI just to collect this parameter.

But it might make sense for the preferred parameter (0, 25 or whatever) to be set alongside the preference switch that decides whether the Trim Editor is going to deliver a cut or a dissolve. That might be a later refinement, but my inclination at the start is to keep it simple.

--
Chris
bidmead is offline  
Old 8th January 2011, 17:32   #206  |  Link
Zarxrax
Registered User
 
Join Date: Dec 2001
Posts: 1,223
I was thinking this could work as a macro, then I saw you mention that qwerpoi wrote you one.
Was the macro insufficient for what you need?
Zarxrax is offline  
Old 8th January 2011, 18:49   #207  |  Link
bidmead
Registered User
 
Join Date: Jul 2007
Posts: 35
The macro requires you to copy the original line and paste it into a text box. It'd be much simpler for the Trim editor optionally just to write out the splice as a zero-frame dissolve. If -- as I'm supposing -- the mod to the core code is fairly trivial.

2Dissolve.py
Code:
entry = avsp.GetTextEntry('Select and copy the trim commands here:')
splitentry = entry.split('++')
if len(splitentry) == 2:
   newString = 'Dissolve(%s, %s, 25)' % (splitentry[0], splitentry[1])
   avsp.InsertText(newString, pos=None)
avsp.SaveScript()
As you can see, this has a 25-frame dissolve parameter hard-coded into it.

--
Chris
bidmead is offline  
Old 8th January 2011, 19:57   #208  |  Link
Zarxrax
Registered User
 
Join Date: Dec 2001
Posts: 1,223
Alright, well I'll take a look into that a little bit later.
Zarxrax is offline  
Old 9th January 2011, 06:17   #209  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,869
Btw, there is a small bug; the status line will print off the screen if you add some parameters. There's two parts, one should be left justified and the other should be right justified.
They are just put together as a string now with an arbitrary space between them, meaning the left part can make the right part go off the edge.
jmac698 is offline  
Old 9th January 2011, 11:28   #210  |  Link
Kripsy
Registered User
 
Join Date: Jul 2006
Posts: 10
Feature request: A way to copy the time code given by the frame number and fps to clipboard.
Kripsy is offline  
Old 9th January 2011, 12:42   #211  |  Link
bidmead
Registered User
 
Join Date: Jul 2007
Posts: 35
Where's that Trim Editor?

I've been wading through qwerpoi's Python code, appreciating the huge amount of work he's done on this, but simultaneously also realising that my early forays into Pascal in the 80's really haven't left me equipped to understand this newfangled OO stuff.

Clearly I must do more work on this. In the meantime, is anyone here able to point me in the direction, however vague, of the Trim Editor code, and in particular, of course, the stanza currently responsible for writing out a splice as "Trim(w,x) ++ Trim(y,z)"?

--
Chris
bidmead is offline  
Old 9th January 2011, 13:38   #212  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,433
Quote:
Originally Posted by bidmead View Post
is anyone here able to point me in the direction, however vague, of the Trim Editor code, and in particular, of course, the stanza currently responsible for writing out a splice as "Trim(w,x) ++ Trim(y,z)"?
I don't have AvsPmod, but in the original AvsP, it's function InsertSelectionTrims in source file AvsP.py.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline  
Old 9th January 2011, 15:50   #213  |  Link
bidmead
Registered User
 
Join Date: Jul 2007
Posts: 35
Thanks, Gavino. No idea why I didn't spot that myself, sorry.

So it looks to me as if the assignment to trimText is what needs changing.

Code:
trimText = ' ++ '.join(['Trim(%i, %i)' % (start, stop) for start, stop in selections])
I take it that "selections" is an array holding the in and out points, so we'd need something along the lines of (I don't know Python at all):

Code:
temptrimText = ' , '.join(['Trim(%i, %i)' % (start, stop) for start, stop in selections])
# gives us "Trim(w,x) , Trim(y,z)"
# then add the Dissolve wrapper
trimText = ''.join('Dissolve(' , temptrimText, ',0)'
Might this work?

--
Chris
bidmead is offline  
Old 9th January 2011, 16:20   #214  |  Link
bidmead
Registered User
 
Join Date: Jul 2007
Posts: 35
Perhaps I should explain the importance (to me at least) of this:

I use AvsP (and now AvsPmod) mostly for rescuing movies from the ravages of the broadcasters. The main assault comes from ad-insertion. It's great that the Avisynth/AvsP combo offers true frame-accurate cutting, but very often this isn't enough if your aim is to remove the ad and leave no suggestion it was ever there in the first place. A straight cut rarely suffices -- there'll be an awkward visual segue, or the sound will be prematurely faded, or whatever.

Avisynth offers a whole bundle of tools to fix this, but but for ad-removal mostly you just want a quick fix that gives a decent result. The all-purpose simple solution is the dissolve, particularly as you have control over the length of the dissolve. A three-frame dissolve, virtually indistinguishable from a cut, to smooth out a sound jump; a 25-frame dissolve to mask an awkward visual transition; a leisurely 75-frame dissolve, where the narrative justifies it, to cover some of the nastier problems.

So more often than not I want the Trim Editor to deliver a dissolve. As a straight splice is just the special case of a dissolve where overlap=0, that's how I'd prefer the Trim Editor to write out the cut.

--
Chris
bidmead is offline  
Old 9th January 2011, 17:48   #215  |  Link
Zarxrax
Registered User
 
Join Date: Dec 2001
Posts: 1,223
bigmead: that change looks to me like it would work. Have you tried running it? I actually don't even have python installed right now so I can't try building it.
If you want to test it yourself (im guessing you don't know how, since you asked if the code would work), you simply need to install python 2.5.4 and wxpython 2.8 for python 2.5.
http://www.python.org/download/releases/2.5.4/
http://www.wxpython.org/download.php#stable

Then you can simply run the modified AvsP.py
Zarxrax is offline  
Old 9th January 2011, 17:50   #216  |  Link
ANGEL_SU
Registered User
 
Join Date: May 2007
Posts: 109
Quote:
Originally Posted by bidmead View Post

Might this work?


Chris
Yes, I try to add 5 lines to source code and it seems to work!

1: At function 'createTrimDialog()', add one more choice:
'_(At script end (use Dissolve))'

2: At beginning of function 'InsertSelectionTrims()', add:
useDissolve = insertMode / 3
insertMode %= 3

3: Just right after the statement 'trimText = ...', add:
if useDissolve:
trimText = 'Dissolve(%s, 0)' % trimText.replace('++', ',')

Last edited by ANGEL_SU; 9th January 2011 at 17:56.
ANGEL_SU is offline  
Old 11th January 2011, 06:32   #217  |  Link
bidmead
Registered User
 
Join Date: Jul 2007
Posts: 35
OK, finally got round to installing python as Zarxrax suggested. And immediately discovered that I wasn't kidding about not knowing Python at all. I'm grateful to you all that my suggested amendment wasn't howled down. In the first place it's missing a bracket at the end (you don't need to know Python to realise that), and in the second place the join function only takes a single argument, not the three I was trying to pile into it.

Angel_Su, you are the hero. :-) I haven't yet implemented the optional switch you propose (but I shall), but the rewrite of trimText you suggest works exactly as I would wish.

Many thanks. Should we offer this as an official patch?

--
Chris
bidmead is offline  
Old 11th January 2011, 07:02   #218  |  Link
bidmead
Registered User
 
Join Date: Jul 2007
Posts: 35
Angel_Su, did you mean:

Code:
 radioBoxTrim = wx.RadioBox(
            dlg, wx.ID_ANY, _('Selection options'),
            choices=(
                _('Keep selected regions'),
                _('Keep unselected regions'),
                _('At script end (use Dissolve)')
             ),
...because this doesn't seem to work for me. It creates a third radio button, which of course means that the other two buttons are unselected.

The "Use Dissolve" switch needs to go elsewhere, doesn't it?

--
Chris
bidmead is offline  
Old 11th January 2011, 18:30   #219  |  Link
Zarxrax
Registered User
 
Join Date: Dec 2001
Posts: 1,223
Quote:
Originally Posted by bidmead View Post
Many thanks. Should we offer this as an official patch?
Well it seems kind of such a specific thing, I'm not really sure if any others would need this functionality.
Opinions?
Zarxrax is offline  
Old 11th January 2011, 18:47   #220  |  Link
ANGEL_SU
Registered User
 
Join Date: May 2007
Posts: 109
@bidmead
search 'choiceBoxInsert':

...
# Create the choice box for insertion options
choiceBoxInsert = wx.Choice(
dlg, wx.ID_ANY,
choices=(
_('At script end'),
_('At script cursor'),
_('Copy to clipboard'),
_('At script end (use Dissolve)'), #add from here
_('At script cursor (use Dissolve)'),
_('Copy to clipboard (use Dissolve)')
)
)
...

Last edited by ANGEL_SU; 11th January 2011 at 19:00.
ANGEL_SU is offline  
Closed Thread

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 08:01.


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