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 23rd January 2021, 20:40   #521  |  Link
JKyle
App Digger
 
JKyle's Avatar
 
Join Date: Sep 2018
Posts: 411
It seems that the new library works well with DPI awareness while the old one does not.

I'm using dual monitors and the scaling factor of my main monitor is 125%.


Under this same setting,



the new library gets the correct numbers



but the old one fails to get them:




But when I turn off DPI awareness,



they both yield the same results,



but this time, they both ignore my manual setting of 130%!


I'm wondering if this is normal, but as for me, I'm happier with DPI awareness off since the menu letter size is too small with DPI awareness.
JKyle is offline   Reply With Quote
Old 24th January 2021, 12:33   #522  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 999
JKyle, thank you for the informative information.
Found the bug.
The DPI value overall can now always be set if 'DPI scaling only manually' is selected.
The other values can always be set and are added to the 'Overall Factor'.

If you like, you can download the modified library.zip here.
__________________
Live and let live
gispos is offline   Reply With Quote
Old 24th January 2021, 13:03   #523  |  Link
JKyle
App Digger
 
JKyle's Avatar
 
Join Date: Sep 2018
Posts: 411
Quote:
Originally Posted by gispos View Post
If you like, you can download the modified library.zip here.
Problem fixed. It's working as expected.
JKyle is offline   Reply With Quote
Old 24th January 2021, 15:41   #524  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 999
AvsPmod 2.6.6.4
Code:
* Resize filters can now be used in the preview filter (nice for SmoothLevel, SmoothCurve debug mode)
* Bugfix DPI scaling
__________________
Live and let live
gispos is offline   Reply With Quote
Old 24th January 2021, 18:37   #525  |  Link
JKyle
App Digger
 
JKyle's Avatar
 
Join Date: Sep 2018
Posts: 411
Since FFMS2 filter(function) definition is missing from ffms2 plugin in AvsPmod, I added it as a new function referring to the ffms2 manual.

Go to Options > AviSynth function definition... > Plugins > New function, and do the following:



Arguments:

Code:
(
string source = ("*.*"),
int "vtrack" = -1 (-1 to 10),
int "atrack" = -2 (-2 to 10),
bool "cache" = True,
string "cachefile" = "" ("*.ffindex"),
int "fpsnum" = -1 (-1 to 60000),
int "fpsden" = 1 (1 to 1001),
int "threads" = -1,
string "timecodes" = "" ("*.txt"),
int "seekmode" = 1 (-1 / 0 / 1 / 2 / 3),
bool "overwrite" = False (False / True),
int "width" = -1,
int "height" = -1,
string "resizer" = "BICUBIC" ("FAST_BILINEAR"/ "BILINEAR"/ "BICUBIC"/ "X"/ "POINT"/ "AREA"/ "BICUBLIN"/ "GAUSS"/ "SINC"/ "LANCZOS"/ "SPLINE"),
string "colorspace" = "" ("YV12"/ "YV16"/ "YV24"/ "Y8"/ "YUY2"/ "YV411"/ "YUV9"/ "RGB24"/ "RGB32"),
int "rffmode"=0 (0 / 1 / 2),
int "adjustdelay" = -1 (-3 / -2 / -1 / 0),
string "varprefix"="",
)
Hope this helps those who use FFMS2 frequently just like me.

---

BTW, the 'Edit function information' window is not resizeable and 'define sliders(Slider information)' window has a very tiny default size.
@gispos, can you please take a look and fix this?
JKyle is offline   Reply With Quote
Old 24th January 2021, 21:38   #526  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 999
Hi JKyle,
have you turned off 'DPI awareness'?
If you use a Win10 system zoom, 'DPI awareness' must be selected in AvsPmod.

You can then choose automatic or manual scaling, but do not completely deactivate the DPI awareness.
Only deactivate the DPI awareness if you are using 100% system zoom.

Show me the window that is too small.
This is how it looks for me when I use 140% AvsPmod DPI scaling.
__________________
Live and let live

Last edited by gispos; 24th January 2021 at 21:44.
gispos is offline   Reply With Quote
Old 24th January 2021, 22:12   #527  |  Link
JKyle
App Digger
 
JKyle's Avatar
 
Join Date: Sep 2018
Posts: 411
Quote:
Originally Posted by gispos View Post
Hi JKyle,
have you turned off 'DPI awareness'?
If you use a Win10 system zoom, 'DPI awareness' must be selected in AvsPmod.
You're right. I've kept it off, and that's why the default 'Slider Information' window size was so tiny.
I wasn't aware that DPI awareness is a mandatory option for a high DPI monitor. :'(
Once I turned it back on, the window size becomes normal. for pointing it out.

BTW, 'Edit function information' window is still unresizeable.
If it's not intended, can you please fix it?
JKyle is offline   Reply With Quote
Old 24th January 2021, 22:46   #528  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 999
Quote:
Originally Posted by JKyle View Post
...
BTW, 'Edit function information' window is still unresizeable.
If it's not intended, can you please fix it?
library.zip x64 only
__________________
Live and let live
gispos is offline   Reply With Quote
Old 24th January 2021, 23:09   #529  |  Link
JKyle
App Digger
 
JKyle's Avatar
 
Join Date: Sep 2018
Posts: 411
Quote:
Originally Posted by gispos View Post
Super! It's fixed.
JKyle is offline   Reply With Quote
Old 24th January 2021, 23:58   #530  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 999
Quote:
Originally Posted by JKyle View Post
Since FFMS2 filter(function) definition is missing from ffms2 plugin in AvsPmod, I added it as a new function referring to the ffms2 manual.
A note:
Take care of your options.dat. All changes are saved in this file. (AvsPmod dir 'options.dat')
I myself make a copy of it every now and then.

And if you unpack a new version in a different directory, you have to copy the old options.dat into the new directory.
Otherwise all your changes will be lost.

I will add your function definition for ffms2 to the database. Then this is available to everyone.
__________________
Live and let live
gispos is offline   Reply With Quote
Old 25th January 2021, 00:20   #531  |  Link
JKyle
App Digger
 
JKyle's Avatar
 
Join Date: Sep 2018
Posts: 411
I see. Thanks.
JKyle is offline   Reply With Quote
Old 25th January 2021, 16:30   #532  |  Link
bruno321
Registered User
 
Join Date: Oct 2018
Posts: 133
Is there a way to stop a preview? Sometimes I input a filter that's just too slow and it'll take hours before it's finished previewing, and I'd rather just stop it.
bruno321 is offline   Reply With Quote
Old 25th January 2021, 20:59   #533  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 999
Quote:
Originally Posted by bruno321 View Post
Is there a way to stop a preview? Sometimes I input a filter that's just too slow and it'll take hours before it's finished previewing, and I'd rather just stop it.
When avisynth is working there is no way to end the process normally.
You can then only terminate the program with a crash.
__________________
Live and let live
gispos is offline   Reply With Quote
Old 26th January 2021, 10:08   #534  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,904
Quote:
Originally Posted by gispos View Post
When avisynth is working there is no way to end the process normally.
You can then only terminate the program with a crash.
Actually I found a life hack xD
If you click "compile" bottom right by mistake and the preview of the next frame is loading, you can minimize AVSPmod really fast, go to your desktop, open it again from the minimized window and just like magic it won't load the next frame.

(please don't "fix" it, it's not a bug, it's a feature I use all the time to avoid huge loading time when I click on the preview by mistake)
FranceBB is offline   Reply With Quote
Old 26th January 2021, 20:56   #535  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 999
Quote:
Originally Posted by FranceBB View Post
Actually I found a life hack xD
If you click "compile" bottom right
I use my native language but I don't know "compile" in the lower right corner.
Quote:
Originally Posted by FranceBB View Post
by mistake and the preview of the next frame is loading, you can minimize AVSPmod really fast, go to your desktop, open it again from the minimized window and just like magic it won't load the next frame.
Please explain that in more detail. Sounds like voodoo to me.
When the script has been passed to avisynth, no program in the world should be able to terminate the process without killing the thread.
Quote:
Originally Posted by FranceBB View Post
(please don't "fix" it, it's not a bug, it's a feature I use all the time to avoid huge loading time when I click on the preview by mistake)
well, let's see
__________________
Live and let live
gispos is offline   Reply With Quote
Old 26th January 2021, 21:48   #536  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 999
I've been trying to understand your voodoo for almost half an hour now. Minimized .. maximized.. everything without success.
You must have a bewitched version. That leaves me with no peace. I can't sleep tonight.
__________________
Live and let live
gispos is offline   Reply With Quote
Old 29th January 2021, 13:16   #537  |  Link
Shinkiro
Registered User
 
Join Date: Dec 2012
Posts: 65
Can anyone tell me if there is a way to force AvsPmod to stop video playback on a scene change?
__________________
Ryzen 2700x | ASUS ROG Strix GTX 1080 Ti | 16 Gb DDR4
Windows 10 x64 20H2
KD-55XE9005 | Edifier R2800
Shinkiro is offline   Reply With Quote
Old 29th January 2021, 17:52   #538  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 999
Quote:
Originally Posted by Shinkiro View Post
Can anyone tell me if there is a way to force AvsPmod to stop video playback on a scene change?
AvsPmod does not have a scene change detection filter.

I had played around with SCDetect a bit and wrote a macro for AvsPmod. But if it was not fully tested, other things came up.

1.) Create a scene change log with SCDetect
2.) Open this file with the macro
3.) Selections are made in AvsPmod. Every 2nd scene is selected.

Don't know if you can do something with it.

SCDetect, tip: Use 'Run analysis pass' I get 63 fps when writing the log file.
Code:
###################################################
###                                             ###
###         Scene change detect script          ###
###                                             ###
###       by 06_taro - astrataro@gmail.com      ###
###                                             ###
###            v0.3 - 12 February 2012          ###
###                                             ###
###################################################
###
### SCDetect - Detect scene change and output scene change frames to a file.
###
### FFTypeList - Output frame type list to a new file.
###              The list has exactly the same format as x264's qpfile, except for no qp value is given.
###
### +-----------+
### | CHANGELOG |
### +-----------+
###
### v0.3 - 12 February 2012:
###      - Add means difference calculation, more accurate on flicking.
###
### v0.2 - 28 December 2011:
###      - Crop before calculate whether the scene change mask is a scene change frame or not,
###        and replace LumaDifference(BlankClip) with YPlaneMax, might be faster.
###      - Tweak parameters of thSCD1 and thSCD2 back to MVTools2's default. The parameters in v0.1 is too weak to detect non-grain clips.
###      - Add FFTypeList to output frame types of source clip. Can be used only with FFVideoSource or FFmpegSource2.
###
### v0.1 - 28 December 2011:
###      - First release.
###
### +----------------+
### |  REQUIREMENTS  |
### +----------------+
###
### SCDetect:
### YV12 input
### -> RemoveGrain
### -> MVTools2
###
### FFTypeList:
### FFVideoSource or FFmpegSource2 as source filter
###
### +-------+
### | USAGE |
### +-------+
###
### SCDetect(scFile, thSCD1, thSCD2, mDiff, pel, search, searchparam, info)
### ----------------------
###
###   scFile [string, Default="scFile.log"]
###   -- The log file of scene change frames, do not output log file when scFile is set to "nul"
###
###   thSCD1 [int, Default=360]
###   -- Threshold which decides whether a block has changed between the previous frame and the current one.
###   -- Raising it will lower the number of blocks detected as changed. It may be useful for noisy or flickered video.
###   -- Read MVTools2 documents for more details.
###
###   thSCD2 [int(0-255), Default=120]
###   -- Threshold which sets how many blocks have to change for the frame to be considered as a scene change.
###   -- 0 meaning 0 %, 255 meaning 100 %.
###
###   mDiff [float, Default=2.5]
###   -- Means difference threshold.
###
###   pel [int(1,2,4), Default=1]
###   -- It is the accuracy of the motion estimation. Value can only be 1, 2 or 4.
###   -- 1 means a precision to the pixel.
###   -- 2 means a precision to half a pixel.
###   -- 4 means a precision to quarter a pixel.
###   -- Larger value is more accurate but slower, and not always better due to big level scale step.
###
###   search [int(0-7), Default=4]
###   searchparam [int, Default=2]
###   -- Search decides the type of search at every level, and searchparam is an additional parameter (step, radius) for this search:
###   -- search = 0 : 'OneTimeSearch'.
###                   searchparam is the step between each vectors tried ( if searchparam is superior to 1, step will be progressively refined ).
###   -- search = 1 : 'NStepSearch'.
###                   N is set by searchparam. It's the most well known of the MV search algorithm.
###   -- search = 2 : Logarithmic search, also named Diamond Search.
###                   searchparam is the initial step search, there again, it is refined progressively. 
###   -- search = 3 : Exhaustive search.
###                   searchparam is the radius (square side is 2*radius+1). It is slow, but it gives the best results, SAD-wise.
###   -- search = 4 : Hexagon search.
###                   searchparam is the range. (similar to x264).
###   -- search = 5 : Uneven Multi Hexagon (UMH) search.
###                   searchparam is the range. (similar to x264).
###   -- search = 6 : pure Horizontal exhaustive search.
###                   searchparam is the radius (width is 2*radius+1). 
###   -- search = 7 : pure Vertical exhaustive search.
###                   searchparam is the radius (height is 2*radius+1). 
###
###   preblur [bool, Default=true]
###   -- Blurring before scene change detection on the clip to avoid affected by grain or not.
###
###   info [bool, Default=false]
###   -- Overlay the result of scene change detection on the clip or not.
###
###
###
### FFTypeList(tlFile, full)
### ----------------------
###
###   tlFile [string, Default="FFTypeList.log"]
###   -- The log file of frame type list.
###
###   full [bool, Default=false]
###   -- Generates list of only I frames or all frames.
###

Function SCDetect(clip c, string "scFile", int "thSCD1", int "thSCD2", float "mDiff", int "pel", int "search", int "searchparam", bool "preblur", bool "info"){

  scFile  = Default(scFile, "scFile.log")
  thSCD1  = Default(thSCD1, 360)
  thSCD2  = Default(thSCD2, 120)
  mDiff   = Default(mDiff, 2.5)
  pel     = Default(pel, 1)
  search  = Default(search, 4)
  searchparam = Default(searchparam, 2)
  preblur = Default(preblur, true)
  info    = Default(info, false)

  last = preblur ? c.RemoveGrain(20, 0) : c
  Assert( IsYV12 , "SCDetect needs YV12 input!" )

  super  = MSuper(pel=pel, chroma=false)
  vector = super.MAnalyse(pelsearch=pel, search=search, searchparam=searchparam, chroma=false)
  scMask = MSCDetection(vector, thSCD1=thSCD1, thSCD2=thSCD2).Crop(0,0,16,16)

  SC_mD = mDiff
  mean = Histogram(mode="Color").Crop(width+64, 64, 128, 128)
  
  # faster with info=True
  SCTrue  = c.Subtitle("Scene change: true" )
  SCFalse = c.Subtitle("Scene change: false")
  info ? ConditionalFilter( last, SCTrue, SCFalse, "boolSC", "==", "true" ) : nop
  
  sss = """
       global boolSC =
  \    (
  \      (scMask.YPlaneMax == 255 ) &&
  \      (
  \        (mean.YDifferenceFromPrevious > SC_mD*3) ||
  \        (
  \          (mean.YDifferenceFromPrevious > SC_mD) &&
  \          (mean.YDifferenceFromPrevious > (mean.YDifferenceToNext+mean.loop(0, 0, -1).YDifferenceToNext+mean.loop(0, 0, 1).YDifferenceToNext)/1.2)
  \        )
  \      )  
  \    )
   (scFile != "nul") ? WriteFileIf( scFile, "boolSC==True", "current_frame" ) : nop
   #info ? (boolSC) ? last.Subtitle("Scene change: true" ) : last.Subtitle("Scene change: false") : last        # slower with info=True
   return last
   """ 
  return ScriptClip(sss, Args="scFile, scMask, SC_mD, mean, info") 
 }

Function FFTypeList(clip c, string "tlFile", bool "full"){

  tlFile = Default(tlFile, "FFTypeList.log")
  full   = Default(full,              false)
  last   = c

  full ? WriteFileIf(tlFile, "true", "current_frame", "chr(32)+chr(FFPICT_TYPE)", append=false)
  \    : WriteFileIf(tlFile, """ chr(FFPICT_TYPE)=="I" """, "current_frame", "chr(32)+chr(FFPICT_TYPE)", append=false)
}
AvsPmod macro
Code:
import wx
re=avsp.GetTextEntry(_('Start from first scene:'), True, 
                     _('Select scene start'), 'check', 200)
if re == '':
    return

filename = avsp.GetFilename(_('Select the scene file'), filefilter=
                            _('Log files') + '|*.log|' +
                            _('Log and Text files') + '|*.txt;*.log|' +
                            _('All files') + ' (*.*)|*.*')

if not filename:
    return
self = avsp.GetWindow()  
txt = self.GetTextFromFile(filename)[0]
txt = txt.strip()
first = re
bookmarkDict = {}
lines = txt.split('\n')
count = len(lines)

try:
    for index, line in enumerate(lines):
        s = line.strip()
        if not s.isdigit():
            raise 
        if first:
            if index == 0:
                bookmarkDict[int(s)] = 1
                if index < count -1:
                    s = lines[index+1].strip()
                    if not s.isdigit(): break
                    bookmarkDict[int(s)-1] = 2
            elif index % 2 == 0:
                bookmarkDict[int(s)] = 1
                if index < count -1:
                    s = lines[index+1].strip()
                    if not s.isdigit(): break
                    bookmarkDict[int(s)-1] = 2
        elif index > 0 and index % 2 != 0:
            bookmarkDict[int(s)] = 1
            if index < count -1:
                s = lines[index+1].strip()
                if not s.isdigit(): break
                bookmarkDict[int(s)-1] = 2 
except:
    bookmarkDict = {}
    avsp.MsgBox(_('Error reading scenes'), _('Error'))
    
if bookmarkDict:
    items = bookmarkDict.items()
    for i, item in enumerate(items):
        value, bmtype = item
        self.AddFrameBookmark(value, bmtype, refreshVideo=False)
__________________
Live and let live

Last edited by gispos; 29th January 2021 at 18:58.
gispos is offline   Reply With Quote
Old 29th January 2021, 18:41   #539  |  Link
gispos
Registered User
 
Join Date: Oct 2018
Location: Germany
Posts: 999
And then I have the macro 'Bookmarks from file.py' If you use it to open the log file, a bookmark is created for every scene change.
Code:
#mod by GPo 2017

import re
import cPickle

filename = avsp.GetFilename(_('Select a file'), filefilter=
                            _('All supported files') + '|*.txt;*.xml;*.ses;*.log;*.qp|' +
                            _('Chapters Text files') + ' (*.txt)|*.txt|'+
                            _('Matroska XML files') + ' (*.xml)|*.xml|' + 
                            _('Celltimes files') + ' (*.txt)|*.txt|' +
                            _('AvsP Session files') + ' (*.ses)|*.ses|' +
                            _('Avisynth files') + ' (*.avs)|*.avs|' +
                            _('TFM log files') + ' (*.log)|*.log|' + 
                            _('XviD log files') + ' (*.log)|*.log|' + 
                            _('QP files') + ' (*.qp)|*.qp|' + 
                            _('Timecode format v1 files') + ' (*.txt)|*.txt|' + 
                            _('All files') + ' (*.*)|*.*')
if not filename:
    return

lines = avsp.GetWindow().GetTextFromFile(filename)[0]

bookmarkDict = {}
Book_Ident = u'#Bookmarks:'

# parsing QP-file (GPo change for title in bookmarks) parse simple txt file
if not bookmarkDict:
    try:
        for index in lines.strip().split('\n'):
            s = index.strip()
            if s != '':
                 a = {}
                 title = ''
                 a = s.split(' ')
                 if a[0].isdigit():
                    if len(a) > 1: 
                       title = str(a[1])
                    if len(a) > 2:  
                       title = title + ' ' + str(a[2]) 
                    bookmarkDict[int(a[0])] = title
    except:
        bookmarkDict = {}

## parse Bookmarks from avs file. #Bookmarks: 32 ,122 MyTitle,544
def findBookmarks_txt():
     txt = {}
     txt = avsp.GetText(index=None, clean=False).split('\n')
     for s in txt:
        #if s.find(Book_Ident) > -1:
          if s.strip().startswith(Book_Ident):
            return s.strip(Book_Ident)
     return ''

## Ein Leerzeichen im title erlaubt   
if not bookmarkDict:
    try:
        ss = findBookmarks_txt() 
        if ss != '':
           for index in ss.split(','):
              s = index.strip()
              if s != '':
                 a = {}
                 title = ''
                 a = s.split(' ')
                 if a[0].isdigit():
                    if len(a) > 1: 
                       title = str(a[1])
                    if len(a) > 2:  
                       title = title + ' ' + str(a[2]) 
                    bookmarkDict[int(a[0])] = title
    except:
        bookmarkDict = {}
        
#################################################################

# parsing Timecode format v1: place a bookmark on every starting frame
if not bookmarkDict:
    if lines.startswith('# timecode format v1'):
        match = re.search(r'^\s*assume\s*(\d*\.*\d+\.*\d*)', lines, re.M|re.I)
        base_fps = (match.group(1) if match else 'unknown') + ' fps'
        bookmarkDict[0] = base_fps
        for line in lines.splitlines():
            if line and line[0].isdigit():
                start, end, fps = line.split(',')
                bookmarkDict[int(start)] = fps + ' fps'
                bookmarkDict[int(end)+1] = base_fps

# parsing SCXviD log
if not bookmarkDict:
    try:
        if lines.startswith('# XviD 2pass stat file'):
            bookmarkDict=dict((i-3,'') for i,v in enumerate(lines.split('\n')) if v.startswith('i'))
    except:
        bookmarkDict = {}

# parsing TFM output
if not bookmarkDict:
    if lines.startswith('#TFM '):
        try:
            stats = lines.split('#   FORMAT:')
            if len(stats)==5:
                sectionslice = (0,(2,-2),(2,-4),(2,-4),(2,-1))
                section = lambda sectionidx: stats[sectionidx].strip().split('\n')[sectionslice[sectionidx][0]:sectionslice[sectionidx][1]]
                sectionisempty = lambda sectionidx: 'none detected' in stats[sectionidx]

                frameindent = 4
                frametitle = lambda line: line[line.find(' ',frameindent+1)+1:]
                framenum = lambda line: int(line[1:line.find(' ',frameindent)])

                dCombed = dict( (framenum(L), frametitle(L)) for L in section(1) ) if not sectionisempty(1) else {}
                dGrouped = dict( (int(F), frametitle(L)) for L in section(2) for F in re.split('[\s,]',L[frameindent:])[:-2] ) if not sectionisempty(2) else {}
                dPossible = dict( (framenum(L), frametitle(L)) for L in section(3) ) if not sectionisempty(3) else {}
                dUBmatch = dict( (int(F),L[-1]) for L in section(4) for F in re.split('[\s,]',L[frameindent:-2]) ) if not sectionisempty(4) else {}
                maxframe = max([max(d.keys()) if d.keys() else -1 for d in (dCombed, dPossible, dUBmatch)])
                if maxframe == -1:
                    avsp.MsgBox(_('Not combed or out of order frames'), _('Bookmarks from TFM file'))
                    return
                s=avsp.GetTextEntry( \
                        [_('Combed') + ' (%d)' % len(dCombed),\
                         _('Possible') + ' (%d)' % len(dPossible),\
                         _('u,b,out-of-order') + ' (%d)' % len(dUBmatch),\
                         '',\
                         _('Min frame:'),\
                         _('Max frame:')],\
                        [True,True,True,'','0',str(maxframe)],\
                        _('TFM log parser'),\
                        ['check','check','check','sep','text','text'],\
                        250 )
                if not s: return

                if s[0]: bookmarkDict.update(dCombed)
                if s[1]: bookmarkDict.update(dPossible)
                if s[2]: bookmarkDict.update(dUBmatch)

                try:
                    f1,f2=int(s[3]),int(s[4])
                    if f1!=0 or f2!=maxframe:
                        bookmarkDict=dict( (f,t) for (f,t) in bookmarkDict.items() if f1<=f<=f2 )
                except:
                    pass

                avsp.GetWindow().GetStatusBar().SetStatusText( _('%d frames imported') % len(bookmarkDict) )
        except:
            raise
            avsp.MsgBox(_('[COMBED FRAMES] section could not be parsed'))
            return

# parsing chapters text files
if not bookmarkDict:
    timeList = re.findall(r'(\d+)=(\d+):(\d+):(\d+\.\d+)', lines)
    if timeList:
        fps = avsp.GetVideoFramerate()
        titleDict = {}
        for index, title in re.findall(r'(\d+)NAME=(.*)', lines, re.I):
            titleDict[index] = title
        for index, hr, min, sec in timeList:
            sec = int(hr)*3600 + int(min)*60 + float(sec)
            bookmark = int(round(sec*fps))
            bookmarkDict[bookmark] = titleDict.get(index, '')

# parsing matroska xml files
if not bookmarkDict:
    sections = re.findall(r'<ChapterAtom>(.*?)</ChapterAtom>', lines, re.I|re.S)
    fps = avsp.GetVideoFramerate()
    for text in sections:
        timecode = re.search(r'<ChapterTimeStart>(\d+):(\d+):(\d+\.\d+)</ChapterTimeStart>', text)
        if not timecode:
            continue
        title = re.search(r'<ChapterString>(.*?)</ChapterString>', text)
        hr, min, sec = timecode.groups()
        sec = int(hr)*3600 + int(min)*60 + float(sec)
        bookmark = int(round(sec*fps))
        bookmarkDict[bookmark] = title.group(1) if title else ''

# parsing celltime format - frame count content
if not bookmarkDict:
    try:
        for index in lines.strip().split():
            bookmarkDict[int(index)] = ''
    except:
        bookmarkDict = {}

# parsing AvsP ssesion files
if not bookmarkDict:
    try:
        f = open(filename, 'rb')
        session = cPickle.load(f)
    except:
        pass
    f.close()
    try:
        if 'bookmarks' in session:
            if 'bookMarkDict' in session:
                for bookmark, btype in session['bookmarks']:
                    bookmarkDict[bookmark] = session['bookMarkDict'].get(bookmark, '')
            else:
                for bookmark, btype in session['bookmarks']:
                    bookmarkDict[bookmark] = ''
    except:
        pass

if bookmarkDict:
    bookmarkList = bookmarkDict.items()
    # Don't delete current bookmarks, update its title if supplied
    #oldBookmarks = avsp.GetBookmarkList()
    #for bookmark, title in bookmarkDict.items():
        #if bookmark in oldBookmarks:
            #if title:
                #bookmarkList.append((bookmark, title))
            #else:
                #bookmarkList.remove((bookmark, title))
    # GPo delete old bookmarks
    avsp.GetWindow().DeleteAllFrameBookmarks()
    avsp.SetBookmark(bookmarkList)
else:
    avsp.MsgBox(_('Bookmark file unrecognized!'), _('Error'))
__________________
Live and let live

Last edited by gispos; 29th January 2021 at 18:57.
gispos is offline   Reply With Quote
Old 29th January 2021, 19:23   #540  |  Link
Shinkiro
Registered User
 
Join Date: Dec 2012
Posts: 65
gispos Thank, I'll try
__________________
Ryzen 2700x | ASUS ROG Strix GTX 1080 Ti | 16 Gb DDR4
Windows 10 x64 20H2
KD-55XE9005 | Edifier R2800
Shinkiro 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 16:09.


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