View Full Version : de-time-multiplexing a video in realtime
jumpjack
31st March 2010, 20:20
I created a new word :) to describe what I need: detimemultiplexing. :)
I have a video device which has one single video output where it puts out 4 different video channels in sequence, 2 secs per each channel.
I have ONE single video capture card on my PC, so I need a SW which can separate the 4 channels, to show them "simultaneously" on the screen: read first channel, put it into top-left corner; read second, put in top right; 3rd -> bottom left, 4th -> bottom right.
I was told Avisynth should be able to do something like this.
Better than this, I would like to interface AviSynth to serial port, to periodically send a pulse over it which commands my device to switch channel, just in case the device timing is not precise (as I suppose).
Does avisynth have some run() or exec() command to start external applications?
IanB
31st March 2010, 23:37
SelectRangeEvery(clip, int "every", int "length", int "offset", bool "audio") (http://avisynth.org/mediawiki/SelectRangeEvery)
So :-..Source(...)
# Assume 2 secs are 50 frames, maybe 60 frames
A=SelectRangeEvery(200, 50, 0) # (240, 60, 0)
B=SelectRangeEvery(200, 50, 50) # (240, 60, 60)
C=SelectRangeEvery(200, 50, 100) # (240, 60, 120)
D=SelectRangeEvery(200, 50, 200) # (240, 60, 180)
X=StackHorizontal(A, B)
Y=StackHorizontal(C, D)
StackVertical(X, Y)
If the source is not 4 random seek friendly then open it 4 times, 1 for each SelectRangeEvery() :-...Source(...)
A=SelectRangeEvery(200, 50, 0)
...Source(...)
B=SelectRangeEvery(200, 50, 50)
...Source(...)
...
And try Call (http://forum.doom9.org/showthread.php?t=46506) and Run (http://avisynth.org/warpenterprises/files/run_25_dll_20050616.zip) plugins.
jumpjack
1st April 2010, 08:43
A=SelectRangeEvery(200, 50, 0) # (240, 60, 0)
I've been told SelectRangeEvery() does not work on realtime videos (rather than video files) as there are no frames to parse/select, but just ONE single frame constantly updated.
Does it exist a "commands reference" for avisynth?
IanB
1st April 2010, 14:01
If you installed the documentation with Avisnth it will be under Start Menu > Programs > AviSynth 2.5 > AviSynth Documentation
There is also the wiki at http://avisynth.org/mediawiki/Internal_filters.
The script above assumes the source is seekable. Live feeds, are by definition unseekable.
jumpjack
2nd April 2010, 13:56
The script above assumes the source is seekable. Live feeds, are by definition unseekable.
so how can I get one frame every X seconds?
IanB
2nd April 2010, 21:19
The script above assumes the source is seekable. Live feeds, are by definition unseekable.so how can I get one frame every X seconds?For live feeds and other sources you cannot seek backwards with, you just skip forwards. SelectEvery(25, 0) will take every 25th frame, the other 24 are discarded.
In the original script it is the StackHorizontal() and StackVertical() that cause seeking. To render the output frame, the script needed the current frame plus the 3 frames 50, 200 and 150 frames earlier.
I take it the 2 second time multiplexed source you mentioned in your first post is a security camera feed that switches to the next camera every 2 seconds and you have 4 cameras. So the stack solution squeezes 8 seconds of data into 2 seconds by displaying 2 seconds worth in each corner. So effectively you display 2 seconds then skip forwards 6 seconds in each corner. One other problem with this is you do not have proper synchronisation to demux the individual camera streams, so the 4 by 2 second windows may in fact contain some frames from 2 adjacent cameras each.
I believe you need to re-think your original display idea in the context of 1 frame in 1 frame out.
One way could be to freeze each quarter window on it's last frame of 2 seconds for 6 seconds, of course you still have the sync problem to resolve.
Gavino
2nd April 2010, 23:50
I believe you need to re-think your original display idea in the context of 1 frame in 1 frame out.
One way could be to freeze each quarter window on it's last frame of 2 seconds for 6 seconds
This script could be used to do that:
src = ... # source clip
b = BlankClip(src)
c1=src c2=b c3=b c4=b
BlankClip(src, width=2*src.width, height=2*src.height)
ScriptClip("""
StackVertical(StackHorizontal(c1, c2), StackHorizontal(c3, c4))
cycle = current_frame%50 == 49 ? 1 + (current_frame/50)%4 : 0
c1 = cycle==1 ? c1.Loop(-1, current_frame, current_frame) : cycle==4 ? src : c1
c2 = cycle==2 ? c2.Loop(-1, current_frame, current_frame) : cycle==1 ? src : c2
c3 = cycle==3 ? c3.Loop(-1, current_frame, current_frame) : cycle==2 ? src : c3
c4 = cycle==4 ? c4.Loop(-1, current_frame, current_frame) : cycle==3 ? src : c4
return last
""")
It seems to work, but perhaps you can come up with a more elegant method, Ian.
jumpjack
3rd April 2010, 13:11
I take it the 2 second time multiplexed source you mentioned in your first post is a security camera feed that switches to the next camera every 2 seconds and you have 4 cameras. So the stack solution squeezes 8 seconds of data into 2 seconds [...]
I actually I was thinking about displaying just ONE frame from each 2-seconds sequence, not the whole 2-secs sequence.
This would result in a poor 1 FPS speed, but I can't see better solutions.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.