Commit Graph

22 Commits (fddbbe259da6091086d457666241a13d3e9c3e23)

Author SHA1 Message Date
jp9000 6377fe3177 win-dshow: Add Virtual Camera (Windows)
The virtual camera adds the ability to use the output of OBS itself as a
camera that can be selected within other Windows applications.  This is
very loosely based upon the catxfish virtual camera plugin design.

There is a shared memory queue, but instead of having 10-20 frames in
the queue, there are now only 3 frames in the queue to minimize latency
and reduce memory usage.  The third frame is mostly to ensure that
writing does not occur on the same frame being read; the delay is merely
one frame at all times.

The frames of the shared memory queue are NV12 instead of YUYV, which
reduces the memory and data copied, as well as eliminate unnecessary
conversion from NV12.  Some programs (such as chrome, which uses webrtc
to capture) do not support NV12 however, so an I420 conversion is
provided, which is far less expensive than YUYV.  The CPU cost of NV12
-> I420 is negligible in comparison.

The virtual camera filter itself is based upon the output filter within
the libdshowcapture library, which was originally implemented for other
purposes.  This is more ideal than the Microsoft example code because
for one, it's far less convoluted, two, allows us to be able to
customize the filter to our needs a bit more easily, and three, has much
better RAII.  The Microsoft CBaseFilter/etc code comprised of about 30
source files, where as the output filter comprises of two or three
required source files which we already had, so it's a huge win to
compile time.

Scaling is avoided whenever possible to minimize CPU usage.  When the
virtual camera is activated in OBS, the width, height, and frame
interval are saved, that way if the filter is activated, it will always
remember the last OBS resolution/interval that the virtual camera was
activated with, even if OBS is not active.  If for some reason the
filter activates before OBS starts up, and OBS starts up with a
different resolution, it will use simple point scaling intermittently,
and then will remember the new scaling in the future.  The scaler could
use some optimization.  FFmpeg was not opted for because the FFmpeg DLLs
would have to be provided for both architectures, which would be about
30 megabytes in total, and would make writing the plugin much more
painful.  Thus a simple point scaling algorithm is used, and scaling is
avoided whenever possible.

(If another willing participant wants to have a go at improving the
scaling then go for it.  But otherwise, it avoids scaling whenever
possible anyway, so it's not a huge deal)
2020-07-07 06:09:59 -07:00
jp9000 7993179466 cmake: Add cmake folders 2020-05-13 06:52:37 -07:00
Matt Gajownik 51be039cf8 CMake: Build Windows modules with file descriptors 2019-10-15 21:34:12 +11:00
jp9000 f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00
jp9000 84613cecff win-dshow: Disable plugin and warn if submodule not found 2016-09-20 05:07:30 -07:00
jp9000 c87d3b1f12 cmake: Rename FindFFMpeg to FindFFmpeg
This was sort of driving me crazy: The 'm' in FFmpeg isn't supposed to
be capitalized.
2015-07-18 16:32:26 -07:00
martell 4f5807e0b0 dshow: link to correct uuid libs
Remove the .lib postfix from strmiids

ksuser provides KSCATEGORY_ENCODER and similar GUIDS used

wmcodecdspuuid provides MEDIASUBTYPE_H264 MEDIASUBTYPE_RAW_AAC1 and
MEDIASUBTYPE_I420 so no need to define them in dshow-formats.  The
submodule will have to be updated to support this change.
2015-02-09 03:41:45 -08:00
jp9000 eb4a05667f win-dshow: Add C985/C353 hardware h264 encoders
This adds support for the AverMedia C985 encoder (which is available on
C985 capture cards) as well as the C353 hardware encoder (which is
currently available on the X99S Gaming 9 motherboards).

These encoders have some limitations, such as limited resolutions
(1280x720 and 1024x768), a max GOP size of 30, and the encoder format
only supports YV12, which requires conversion if the current output
format isn't the same.  The C985 and C353 encoders seem to be pretty
much identical, although it seems like the C353 has a bit more efficient
encoding.

I don't believe these are really suitable for streaming, as they do not
really have the encoding efficiency needed to stream at lower bitrates,
and seem to only support variable bitrate.  However, for recording these
encoders are quite nice to have available, and work quite well.
2014-12-21 10:14:27 -08:00
jp9000 bbff0eeeb9 win-dshow: Move module loading to separate file
The main module code was originally all packed in to the win-dshow.cpp
file, which isn't exactly ideal or clean if one wants to add other
things to the module as a whole.
2014-12-21 10:14:26 -08:00
jp9000 67587fbced win-dshow: Allow use of YV12 video format
Previously, due to a bug in libdshowcapture, the NV12 format was
actually being used for YV12 erroneously, and no actual support for YV12
existed.  This fixes the bug with NV12 and adds support for YV12.
2014-12-21 10:14:26 -08:00
jp9000 77f0f6802a win-dshow: Put device id mangling in separate file
This is going to be used for other code as well, so may as well put it
in its own file.
2014-12-21 10:14:25 -08:00
BtbN 599febcb54 cmake: Replace FFMpeg modules with single module
Now using components instead of one find_package call per module
2014-09-27 09:41:13 -07:00
jp9000 24ae80a481 win-dshow: Implement decoding of encoded devices 2014-09-12 20:36:33 -07:00
jp9000 755f95a3a7 win-dshow: Add FFmpeg decoding support 2014-09-12 20:36:32 -07:00
jp9000 f3c47796ab Update libdshowcapture to 0.2.1 (HD-PVR 1 support) 2014-09-06 14:00:47 -07:00
jp9000 6c14dbe6ff Update libdshowcapture to 0.2.0 2014-09-06 12:45:21 -07:00
BtbN 02725acdd4 Fix double invocation of install_obs_plugin in every single plugin 2014-08-19 14:24:59 +02:00
BtbN 38c2fc87aa Move all data into the subdir it belongs to
Completely removes the build dir in favor of cmake based build layouting
2014-07-19 01:38:41 +02:00
jp9000 482791c5b6 Add locale for modules 2014-07-11 17:29:00 -07:00
jp9000 040615c6bc Fix CMakeLists.txt yet again 2014-05-30 03:45:34 -07:00
jp9000 40f9448a83 Fix win-dshow module CMakeLists.txt
Didn't include the DirectShow library, and forgot to add one source file
2014-05-30 03:43:53 -07:00
jp9000 c55b1771cd Add preliminary DirectShow capture plugin
This covers the basics of devices.  Mostly functional but not at 100%
yet.  Uses 'libdshowcapture' library to capture directshow video/audio.
Both libdshowcapture and the plugin still need some work.  Should at
least capture basic webcams and capture cards for the time being.
2014-05-30 03:29:48 -07:00