Log in

View Full Version : Quad-frame video


jdean438
28th May 2004, 21:54
I'm looking for a way to automatically separate four quarter-frame video streams out of a 'Quad-frame' type surveillance videotape. This seems like something that AVIsynth should be able to excel at, I think.

Each full video frame is made up of four quadrants each fed from a different camera.The source material is coming to me on SLP-format, NTSC VHS tape and I intend to capture that straight into DV

The video is initially assembled with a commercial 'digital' multiplexor from a dedicated fixed four-camera setup over which I have no control. I'm trying to anticipate and plan for the best way to handle what I'm dealt. (I'm just lucky the contractor didn't go for the 40-hr mode on the VCR. As it is the VCR automatically rewinds and keeps recording after six hours.)

Is there a filter available yet that can split full sized DV frames into four quarters in one pass? ...or how difficult would it be to create one? (any interest out there?) What would the script look like? (Any cropping, resizing etc needed because it's out of VHS?)

After the four streams are separated I can worry about things like fixing the focus, getting the sun-glare out of the picture, removing image vibration (did I mention this is all flying on a helicopter???) and....

Any and all suggestions welcome--including capture and post-processing and indeed the whole concept of how I'm approaching it right now.

Thanks in advance.
James,
Ottawa

stickboy
29th May 2004, 05:53
Not tested.
# GetQuadrant
#
# Returns a clip generated from the specified quadrant
#
# PARAMETERS:
# quadrant - the quadrant number [1, 4];
# this function numbers quadrants as:
# 1 | 2
# ---+---
# 3 | 4
#
# USAGE:
# AVISource("foo.avi")
# q1 = GetQuadrant(1)
# q2 = GetQuadrant(2)
# q3 = GetQuadrant(3)
# q4 = GetQuadrant(4)
# q1 ++ q2 ++ q3 ++ q4
# LanczosResize(720, 480)
#
function GetQuadrant(clip c, int quadrant)
{
quadrant = quadrant - 1
Assert(quadrant >= 0 && quadrant < 4,
\ "QuadrantSource: invalid quadrant")

midX = c.Width() / 2
midY = c.Height() / 2

w = midX
h = midY

return Eval(Select(quadrant,
\ "c.Crop( 0, 0, w, h)",
\ "c.Crop(midX, 0, w, h)",
\ "c.Crop( 0, midY, w, h)",
\ "c.Crop(midX, midY, w, h)"))
}

Leak
29th May 2004, 09:02
Originally posted by stickboy
Not tested.

If I understood jdean438 correctly, he was looking for a solution to produce 4 AVI files in one pass instead of doing 4 passes, which would only be doable if AviSynth itself had something like an AVIWriter() command...

Then again, as decoding the video is hardly the most CPU intensive part doing it in 4 passes should be just a tad slower - it's encoding the 4 new videos that'll take the most time.

np: Apollo 440 - Cold Rock The Mike (Getting High On Your Own Supply)

stickboy
29th May 2004, 09:48
My interpretation is that since he wants to do additional processing after splitting up the video that writing the AVI files would be the very last step. Why make unnecessary intermediate files?

Well, anyway, if he wants to do what you say, then make four AviSynth scripts and queue up four VirtualDub jobs. Whenever you need to process a new video, rename it to whatever filename the scripts use, run the VirtualDub jobs, and rename the original file back when done (if so desired).

Just watch out for VirtualDub's stupid feature of saving frame-counts in the VirtualDub.jobs file even if you don't make any edits within VD.

jdean438
3rd June 2004, 20:38
This is correct. I want a filter (or a proceedure) that will take input file "foo.avi" and end up with four output files -call them "foo_1.avi", "foo_2.avi", "foo_3.avi", "foo_4.avi" -each corresponding to the numbered quadrant above. I'm not sure that upsizing to full frame is necessary, only if required for further processing to work properly.

Is there a 'crop' tool available now or is this something that needs to be built?

James
------


Originally posted by Leak
If I understood jdean438 correctly, he was looking for a solution to produce 4 AVI files in one pass instead of doing 4 passes, which would only be doable if AviSynth itself had something like an AVIWriter() command...

Then again, as decoding the video is hardly the most CPU intensive part doing it in 4 passes should be just a tad slower - it's encoding the 4 new videos that'll take the most time.

np: Apollo 440 - Cold Rock The Mike (Getting High On Your Own Supply)

stickboy
4th June 2004, 11:25
Originally posted by jdean438
This is correct. I want a filter (or a proceedure) that will take input file "foo.avi" and end up with four output files -call them "foo_1.avi", "foo_2.avi", "foo_3.avi", "foo_4.avi" -each corresponding to the numbered quadrant above.AviSynth doesn't generate AVI files itself; it's a frame-server. You need to load the scripts into something else (e.g. VirtualDub).

As I said, you're probably better off making reusable VirtualDub jobs. I'll post a more thorough explanation over the weekend if you want.

stickboy
6th June 2004, 04:19
Run VirtualDub. Load your file (AVI file, AviSynth script, whatever).
Set your Video and Audio compression settings.
Select "File > Save as AVI". Enable the "Don't run this job now..." checkbox.
Quit VirtualDub.
Go to the VirtualDub folder, and open the VirtualDub.jobs file in a text editor.
Scroll down to the bottom of the file. The last job should correspond to the one you just created.
There should be two lines that look like:
VirtualDub.subset.Clear();
VirtualDub.subset.AddRange(0,1442);(The numbers in the AddRange line will be different.) Delete them and replace them with:VirtualDub.subset.Delete();(It's stupid that the above steps are even necessary. Things weren't always this way. I've bugged Avery about it, but he's been ignoring me. :( )

Now whenever you want to re-run that job, repeatedly double-click on it in VirtualDub's Job Control window until its status turns to "Waiting". (You also can edit the VirtualDub.jobs file directly and set that job's $state value to 0. Make sure all instances of VirtualDub are closed before editing the jobs file.)

You can have the VirtualDub job always load the same AviSynth script. When you need to process a new video file, you can either: Edit the AviSynth script to load that new file
Have the AviSynth script always load a file with a standard filename, and whenever you have a new video file to process, rename it to that name.In your case, you can have four separate AviSynth scripts, each one selecting a specific quadrant. You then can create four VirtualDub jobs to output four AVI files. (If you want, you can edit the VirtualDub.jobs file to combine them all into one single job; then you won't need to reset the job status so many times.)