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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 3rd March 2014, 10:04   #1  |  Link
fieliapm
Himawari Tachibana
 
fieliapm's Avatar
 
Join Date: Nov 2013
Location: Taipei, Taiwan
Posts: 12
VideoInputSource - grab video frame from video capture card or webcam in real-time

It is developed for my work in the beginning. But I think somebody might need this to processing real-time captured video, so I post here and wish I could help anyone who use AviSynth to do some prototyping easily.

One day, I am asked to import and process real-time captured video and merge with video from files in AviSynth for making some prototype.
In the beginning, I grabbed video frame from DirectShowSource() with grf file as input. However, I found that DirectShowSource() won't duplicate or skip frame when some video capture device (ex. webcam) cannot produce next frame ontime. This phenomenon will cause AviSynth's frame feeding slow down while playing AviSynth script.
For this reason, I made a AviSynth source filter which capture video from video capture device. It is based on a simple video capture library named VideoInput.



binary:
VideoInputSource.x86.dll built for x86 32bit AviSynth 2.5.7 & VapourSynth API version 3.6
VideoInputSource.x64.dll built for x86 64bit VapourSynth API version 3.6

source:
VideoInputSource on github



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; 25th August 2024 at 13:31. Reason: Support VapourSynth
fieliapm is offline   Reply With Quote
 

Tags
avisynth, videoinput, webcam

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:03.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.