Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- # Usage:
- ep = "01"
- logBlackBorders(ep+".borders.log", ep+".xvid")
- #or:
- logBlackBordersRF(ep+".borders.log", ep+".framelist.txt")
- #or:
- logBlackBordersRF(ep+".borders.log", "0 178 223 261 269 355 364 453 464 526 554 618 754 854 923 944")
- # Log example:
- 1668 Top Bottom
- 1669 Left Top Right Bottom
- 1670 Top Bottom
- 1680 Top Bottom
- # For logBlackBordersRF() the plain list of frames (scenecuts) can be generated by the batch file below.
- # Multiple xvid logs may be specified, for each one a new file with .remfs.txt suffix is created.
- # It's also possible to simply drag'n'drop multiple xvid log files onto the batch file in Explorer.
- @echo off
- if "%~1"=="" echo Usage: scxvid2remfs 01-xvid.log 02-xvid.log 03-xvid.log & exit/b
- :loop
- (
- for /f "delims=:" %%a in ('findstr /bn "i" "%~1"') do (
- set /a frame=%%a-4
- setlocal enableDelayedExpansion
- echo !frame!
- endlocal
- )
- )>"%~n1.remfs.txt"
- shift
- if not "%~1"=="" goto loop
- # Code:
- */
- function logBlackBorders(clip c, string logfile, val scxvid_maskorfile, int "bordersize", int "lumathreshold") {
- bord = default(bordersize, 1)
- thr = string(default(lumathreshold, 20))
- c.converttoy8()
- mask = isclip(scxvid_maskorfile) ? scxvid_maskorfile
- \ : isstring(scxvid_maskorfile) ? SCXvidMask(scxvid_maskorfile)
- \ : assert(false, "logBlackBorders: 'scxvid' parameter should be a clip or a file name string")
- L = mt_lutf(last, "max", "x", w=bord).crop(0,0,1,1)
- T = mt_lutf(last, "max", "x", h=bord).crop(0,0,1,1)
- R = mt_lutf(last, "max", "x", offx=c.width-bord).crop(c.width-1,0,1,1)
- B = mt_lutf(last, "max", "x", offy=c.height-bord).crop(0,c.height-1,1,1)
- mask.converttoy8.crop(0,0,4,1)
- conditionalfilter(last,
- \ writefileif(stackhorizontal(L, T, R, B), logfile, "YPlaneMax(75) <= "+thr, """
- string(current_frame)
- \ + (crop(0,0,1,0).YPlaneMax <= """ + thr + """ ? " Left" : "")
- \ + (crop(1,0,1,0).YPlaneMax <= """ + thr + """ ? " Top" : "")
- \ + (crop(2,0,1,0).YPlaneMax <= """ + thr + """ ? " Right" : "")
- \ + (crop(3,0,1,0).YPlaneMax <= """ + thr + """ ? " Bottom" : "")
- """, append=false, flush=true),
- \ last,
- \ "YPlaneMin", "=", "255")
- }
- /***********************************************************************************************/
- function logBlackBordersRF(clip c, string logfile, string scenecuts_stringorfilename, int "bordersize", int "lumathreshold") {
- bord = default(bordersize, 1)
- thr = string(default(lumathreshold, 20))
- c.converttoy8()
- L = mt_lutf(last, "max", "x", w=bord).crop(0,0,1,1)
- T = mt_lutf(last, "max", "x", h=bord).crop(0,0,1,1)
- R = mt_lutf(last, "max", "x", offx=c.width-bord).crop(c.width-1,0,1,1)
- B = mt_lutf(last, "max", "x", offy=c.height-bord).crop(0,c.height-1,1,1)
- writefileif(stackhorizontal(L, T, R, B), logfile, "YPlaneMax(75) <= "+thr, """
- string(current_frame)
- \ + (crop(0,0,1,0).YPlaneMax <= """ + thr + """ ? " Left" : "")
- \ + (crop(1,0,1,0).YPlaneMax <= """ + thr + """ ? " Top" : "")
- \ + (crop(2,0,1,0).YPlaneMax <= """ + thr + """ ? " Right" : "")
- \ + (crop(3,0,1,0).YPlaneMax <= """ + thr + """ ? " Bottom" : "")
- """, append=false, flush=true)
- \ .remfs(mappings=exist(scenecuts_stringorfilename) ? undefined : scenecuts_stringorfilename,
- \ filename=exist(scenecuts_stringorfilename) ? scenecuts_stringorfilename : undefined)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement