View Single Post
Old 8th April 2017, 09:55   #6  |  Link
fieliapm
Himawari Tachibana
 
fieliapm's Avatar
 
Join Date: Nov 2013
Location: Taipei, Taiwan
Posts: 8
The problem which lansing and Chromix met might be due to getPixels() is non-blocking at their environment or usage.
However when I use VirtualDub to encode, with my capture card and Microsoft LifeCam Cinema under Windows 7, GetFrame() always blocks at getPixels() while there is no new frame coming.
To ensure new frame coming by asking function isFrameNew() (as Chromix did in modified version), I refined my original source code and put it here:

binary:
VideoInputSource.dll

source:
VideoInputSource on github

Just make frame_skip = false, it will acts like frame_wait in Chromix's mod.

I also use BitBlt() from AviSynth script env instance plus _aligned_malloc() to accelerate frame data copy, because AviSynth offers BitBlt() which support SSE instruction set when it availabie, it might be more efficient while running on various CPUs.

It is based on old stable release videoInput 0.1995 as previous revision.
However, anyone who want to use newer version (ex. 2014) of videoInput from author Theodore Watson's github (videoInput on github), feel free to switch source code belong to videoInput 0.1995 to newer version.



BTW, let me re-introduce this source plugin again.

The usage of this source filter is as below:
Code:
VideoInputSource(device_id,connection_type,width,height,"fps_numerator","fps_denominator","num_frames","frame_skip")

# device_id: the n-th number of video capture device in your computer

# connection_type: can be these string: "Composite","S_Video","Tuner","USB".
#     I leave this parameter because videoInput library offer this option.

# width, height: the width and height of frames captured from video capture device.

# fps_numerator, fps_denominator: FPS numerator and denominator.
#     Default is 30/1 (30.0fps)

# num_frames: How many frame will be captured from video capture device.
#     This will tell AviSynth the length of this video source.
#     Default it will be the value which makes video source length become 24 hours.

# frame_skip: enable/disable frame skip while next new frame from video capture device is not ready.
#     Default is true.
For example:

Code:
VideoInputSource(0,"Composite",1920,1080,24,1)
Will grab video from video capture device #0, 1920x1080, 24.0 fps, 24 hours long.

videoInput always output BGR24 packed pixels. For efficiency, current version of VideoInputSource supports AviSynth RGB24 color format only, and cannot be imported into VapourSynth script yet. Since I sometimes use VapourSynth for video processing, I might focus on compatibility of VapourSynth in the future.

By the way, It can work with MP_Pipeline very well since I often test this plugin in separate process generated by MP_Pipeline. However this plugin exclusively accesses to video capture device, so don't create video source from the same video capture device at the same time.

Last edited by fieliapm; 8th April 2017 at 09:58. Reason: typo
fieliapm is offline   Reply With Quote