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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 20th February 2009, 02:48   #1  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
EDLmaker - simple scenechange detector that writes to EDL file...

i'm going to be getting a fair bit of use out of this, so i might as well share it.

this little script takes a clip and makes a CMX formatted EDL file when it finds what looks like a scenechange. there's some simple logic in there to try and catch fades and other things and stop them being written as events, but overall it's quite simple and pretty quick.

Code:
function EDLmaker (clip c, string filename)
{
global d=c.reduceby2()

global d1=mt_lutxy(d.selectevery(1,-1),d.selectevery(1,0),expr="x y - abs")
global d2=mt_lutxy(d.selectevery(1,0),d.selectevery(1,1),expr="x y - abs")
global d3=mt_lutxy(d.selectevery(1,1),d.selectevery(1,2),expr="x y - abs")

global cut=0
global inpoint=0
global outpoint=0
global event=1

eval1=c.frameevaluate("""global cut = d1.averageluma-(d2.averageluma+d3.averageluma)/2 > 20 ? 1 : 0 """)
eval2=frameevaluate(eval1,"""global outpoint = current_frame """)
eval3=frameevaluate(eval2,""" global event = cut==1 ? event + 1 : event """)
eval4=writefileif(eval3,filename,"cut == 1 || current_frame==d.framecount-1", """ string(event,"%03.0f") + "  001      V     C        " + itc(inpoint) + " " + itc(outpoint) + " " + itc(inpoint) + " " + itc(outpoint)""") 
frameevaluate(eval4,""" inpoint = cut==1? outpoint : inpoint """)
}

function tc (string "timecode", float "rate")
{
	rate=default(rate,25)
	
	frames=value(rightstr(timecode,2))
	secs=value(rightstr(timecode,5).leftstr(2))*rate
	mins=value(rightstr(timecode,8).leftstr(5))*60*rate
	hours=value(rightstr(timecode,11).leftstr(8))*60*60*rate
	int(hours+mins+secs+frames)
}

function itc (int "framecount", float "rate", bool "ms")
{
	rate=default(rate,25)
	ms = default(ms, false)
	
	drop = (rate==29.97)? true : false
	rate2 = (drop==true)? 30 : rate
	
	hours=floor((framecount/rate)/3600)%60
	mins=floor((framecount/rate)/60.0)%60
	secs=floor(framecount/rate)%60
	milli=floor(1000*framecount/rate)%6000%1000
	fmilli=framecount/rate - floor(framecount/rate)
	#frames=floor(fmilli*rate2)
	frames=framecount%int(rate)
	
	dframes = (drop==false)? frames : (secs==0)&&(mins%10!=0)? floor(fmilli*rate2) + 2 : frames
	
	return (ms==false)? (string(hours,"%02.0f")+":"+string(mins,"%02.0f")+":"+string(secs,"%02.0f")+":"+string(frames,"%02.0f")) :
\	(string(hours,"%02.0f")+":"+string(mins,"%02.0f")+":"+string(secs,"%02.0f")+":"+string(milli,"%03.0f"))
}
hope someone gets some use out of this... i certainly will next time i'm forced to use apple's excuse for a colour grading program.

[edit]

here's an example of the output:

Code:
001  001      V     C        00:00:00:00 00:00:02:00 00:00:00:00 00:00:02:00
002  001      V     C        00:00:02:00 00:00:04:03 00:00:02:00 00:00:04:03
003  001      V     C        00:00:04:03 00:00:06:22 00:00:04:03 00:00:06:22
004  001      V     C        00:00:06:22 00:00:09:14 00:00:06:22 00:00:09:14
005  001      V     C        00:00:09:14 00:00:10:20 00:00:09:14 00:00:10:20
006  001      V     C        00:00:10:20 00:00:11:18 00:00:10:20 00:00:11:18
007  001      V     C        00:00:11:18 00:00:13:08 00:00:11:18 00:00:13:08
008  001      V     C        00:00:13:08 00:00:15:08 00:00:13:08 00:00:15:08
009  001      V     C        00:00:15:08 00:00:17:17 00:00:15:08 00:00:17:17

...etc etc
__________________
sucking the life out of your videos since 2004

Last edited by Mug Funky; 20th February 2009 at 04:58.
Mug Funky is offline   Reply With Quote
 

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 14:44.


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