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. |
|
|
Thread Tools | Search this Thread | Display Modes |
20th February 2009, 02:48 | #1 | Link |
interlace this!
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")) } [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. |
21st February 2009, 13:04 | #2 | Link |
Registered User
Join Date: Mar 2005
Posts: 366
|
Very nice idear.
I guess this concept could also could be used for doing the color corrections within Avisynth. I mean if the resulting file was an avs script with a trim command for each clip paired with with color/contrast etc. correction commands. Then this script could be loaded in AvsP and with the AvsP gui slider functions one could easily go through the entire film and correct each clip. It could be fun to try that concept out or even try to add this as a more permanent function in AvsP. Anyway good work(and sorry for the thread-jacking)
__________________
DVD slideshow GUI(Freeware). |
23rd February 2009, 01:21 | #3 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
that is a good idea, but i fear avisynth would have to be greatly expanded to be usable as a grading program. bear in mind that in my opinion, not even Apple's Color could be considered a "usable" grading program. i've never said the "c" word more than when using this program.
true enough, avs already supports GPU rendering, 3d LUTs, 2d LUTs, advanced denoising (better than in any grading program), de-spotting, sharpening, etc. what it lacks is more than 8 bits. we'd need float to make it a really good option, and also need genlock, SDI output and RS232 interface with a variety of tape decks, as well as fast enough processing to do HD in realtime. there's always the dream though. think what an opensource finishing tool could do to the indie world? i think i'd be out of that much more work though...
__________________
sucking the life out of your videos since 2004 |
24th February 2009, 04:19 | #5 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
float is better. it's better to process in more bits than you're finishing in, as most grading happens in layers, and though it could be possible to collapse the whole multi-layered grade into a single 3d LUT to avoid this, things like "power windows" and defocus operations can't be done in LUTs.
...that said, i've done avs noise reduction in 8 bits and haven't spotted it on the film-out. in fact, i couldn't see the noise reduction artefacts even knowing what to look for... useful. tell you what though, MC'd noise reduction scripts in 2048x1260 (and cheated for RGB) are quite slow
__________________
sucking the life out of your videos since 2004 |
26th February 2009, 11:10 | #6 | Link |
Registered User
Join Date: Mar 2005
Posts: 366
|
__________________
DVD slideshow GUI(Freeware). |
30th August 2014, 21:39 | #7 | Link |
Registered User
Join Date: May 2005
Posts: 1,462
|
EDLmaker looks fantastic! Looks like I could write a small Perl script or something to turn it into something Avisynth can use (for trimming/splitting).
One question, though, is it guaranteed to split on key-frames? I'd hate having to start encoding on parts that start on a B-Frame or something (as I'll have to combine the parts later). Thanks.
__________________
Gorgeous, delicious, deculture! |
30th August 2014, 21:58 | #8 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
Keyframes may or may not be at scene start (depends how good the encoder scene change detector was and already said how good they are) and also on how clip was encoded (eg occasionally see a single keyframe as frame 0 for an entire clip [usually badly encoded DIVX]). MugFunky thread was from 2009, dont know if he is currently about. Smok3 is working on an EDL list creator here: http://forum.doom9.org/showthread.php?t=170700 I am working on scene change detector which I hope will blow others away (already works better than anything Im aware of) and unpublished version will create an RT_Stats DBase of scene changes, using script funcs, can then extract eg frames ranges or EDL. Thank you for resurrecting this thread, I was wondering how to handle the drop frames thing for creating EDL lists.
__________________
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 ??? Last edited by StainlessS; 30th August 2014 at 22:47. Reason: speeling |
|
30th August 2014, 23:23 | #9 | Link |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,695
|
I've got four different scripts for detecting scene changes. Each uses a different method: MvTools; ScSelect; Depan; and YDifferenceToNext. Each has its own strengths. The usual thing that fools them is when something large enters the scene close to the camera, typically someone who walks in front of me. Quick camera pans can also fool these scene detection scripts, and I often have problems when trying to do scene detection on sports like football where the camera pans quickly to follow the action.
These will be the big challenges for you as you attempt to finally "solve" this problem. There are also pathological cases, but you can probably ignore these. Strobe lights will cause most scene detection to fail, but those are pretty rare. Also, jump cuts often are not caught. I had very good success using your motion detection for security camera applications. Hopefully you can adapt some of that same code to solve this much more widespread problem. |
31st August 2014, 00:43 | #10 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
As far as the multiple flash frames thing is concerned, currently got a version that almost works (not the DBase thing mentioned above, only
just done that over the last couple of days). I think now I've done the DBase version, will be easier to incorporate the multiflash override functionality. A surprising offshoot of the multiflash thing is that it can 'ignore' global luma variances over about 4 frames, lightning flashes and explosions or someone opening a door and letting light into a room. I'm starting with a 'hair trigger' detector, and then want to be able to override the very sensitive detections (so overrides only need be done on the relatively rare +ve detections and not on non detect frames). Hopefull I'll also be able to incorporate a user override function to set frames to scene change or not scene change. Still some way to go but its getting better, If I can get it performing as desired, it will likely become a plug function. The DBase thing currently acts just like SCSelect (but much less brain dead), but creates a DBase as it scans, you can scan backwards over previously visited frames, but if you jump forwards to previously un-visited frames, then it scans forwards from highest visited frame number up to the jump frame, setting DB as it goes (so would seem to hang for a time). The necessity to scan all frames between last visited and jump frame makes it easier (or possible) to implement the multiflash (and other overrides), as jumping to any old frame would require pretty much an unlimited number of frames previous to jump frame to be scanned (there could have been overrides previous to the jump position and the only real way to be sure to be in 'override sync' would be to scan from frame 0). If you eg do a Video Analysis pass in VDub, you can then jump to any frame. Something large entering the frame will probably be a SC detect problem for a long time, until machines can perceive as we do. Might be able to improve for quick camera pans. Strobe lights, am curious to see if the mutiflash thing can ignore that, but if constant, then is likely to slow scanning quite a bit. Quote:
__________________
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 ??? Last edited by StainlessS; 31st August 2014 at 00:59. |
|
31st August 2014, 06:56 | #11 | Link | |
Registered User
Join Date: May 2005
Posts: 1,462
|
Quote:
__________________
Gorgeous, delicious, deculture! |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|