View Full Version : How can I cut video to scenes automatically?
Bence
25th August 2005, 08:20
I would like to cut each scenes to separate files for further editing. How can I automatize this?
There are hours of video, digitized from analog source (no timestamp), cut them manually is a nightmare, altough AviSynth seems an appropriate tool to the job automatically.
mg262
25th August 2005, 08:43
AviSynth seems an appropriate tool to the job automaticallI'm curious as to what makes you say that? AVISynth outputs a single uncompressed video stream, so it doesn't seem to me to be the natural choice for something like this. (Googling "cut video to scenes automatically?" turned up some programs that would do it.) Now a hybrid approach, using AVISynth to detect the scenes (and list them in a text file, say) and another program to cut seems quite promising to me...
Bence
25th August 2005, 10:39
Yes, hybrid approach can be made. My idea:
1. AVISynth creates a text file of differences
2. VB script to create a VirtualDub job list (based the AVISynth result).
3. VirtualDub batch executes the jobs.
I hoped, there is a more compact solution.
(I dont' know any other application to do this. Pinnacle studio detects scene changes, but it does not cut the file.)
Said, AVISynth seems good tool for this, because I could detect and record frame differences with it - what is already the half of the job.
lamer_de
25th August 2005, 11:05
SClav should be able to give you a log at least. Or maybe it does exactly what you want:
http://students.washington.edu/lorenm/src/avisynth/sclavc/
There's also a filter by shodan somewhere in these forums that can detect scenechanges as well. Use search.
CU,
lamer_de
mkanel
26th August 2005, 17:00
Bence,
Is this what you're looking for? This script will write a series of AVS scripts, Seg 1.avs, Seg 2.avs, Seg 3.avs, etc.
If that's what you have in mind it wouldn't be too hard to modify this to your needs and make it a general use function. I'm sure it could also be written more concisely.
To use this just change the video path in lines 5 and 6 to suit your needs and play it in anything that can read an AVS script. The quickest method would probably be to open it in VirtualDub and select video analysis pass.
#Change lines 5 and 6 to reflect your video
Global SegmentNumber=1
Global OutputPath="C:/" #Set path here.
Global SourceFile="""AVISource("C:\MyVideo.avi") """ #Match to next line
AVISource("C:\MyVideo.avi").converttoyv12 #or mpeg2source(myvideo.d2v)
FrameEvaluate("""current_frame==Framecount(last)-1 \
?WriteLast(segmentnumber,current_frame) :nop""")
FrameEvaluate("""YDifferenceToNext>40 \
?WriteSegment(segmentnumber,current_frame) :nop""")
FrameEvaluate("""SegmentNumber = YDifferenceToNext>40 \
?SegmentNumber+1 :SegmentNumber""")
WriteFileStart( OutputPath+" SEG "+string(SegmentNumber)+ ".avs","SourceFile","chr(10)",
\""" "Trim(0, \" """)
function WriteSegment (int SegmentNumber, int frame)
{
WriteFileStart(version, OutputPath+" SEG "+string(SegmentNumber)+ ".avs",
\ "string(frame)", """ ")" """,append=True)
WriteFileStart(version, OutputPath+" SEG "+string(SegmentNumber+1)+ ".avs",
\"SourceFile","chr(10)",""" "Trim(" """, "string(frame+1)", """ ", \" """)
}
function WriteLast (int SegmentNumber, int frame)
{
WriteFileStart(version, OutputPath+" SEG "+string(SegmentNumber)+ ".avs",
\ "string(frame)", """ ")" """,append=True)
}
Good luck. Mike.
Bence
29th August 2005, 11:24
Mike,
yes, that's what I need.
Thanks a lot!
Bence
mkanel
29th August 2005, 13:32
Bence,
You're welcome. Glad to help. :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.