Is it possible to control 2 DirectShowNet streams from one input? - c#

I am using DirectShow.Net in C#. I made a player that will stream video from a usb device to a video screen and to an avi file at the same time.
I want to have a button so the video will preview on the screen but not capture until a button is pressed. currently to do this, i have to redo the graph and add in the capture filter renderstream.
is it possible to create 2 different graphs off of 1 input? so I would have my usb camera that is displaying to a video window and then when i press a button i can create a second graph that will save the video from the camera to a file while its still playing on screen?

As mentioned by #Geraint, you can use GMFBridge with DirectShow.Net. DirectShow.Net website states:
Samples\Misc\GMFPreview
----------------------- A sample showing how to use Geraint's
indispensible GMFBridge tool to allow
part of a graph to be stopped while
another part keeps running. This is
useful to allow preview windows to
keep running while you start/stop
capturing to disk.

Related

C# How to keep the DirectShow filter graph running on video window resize, minimize, device lost, reset?

Our app is using C#/WinForms/VMR9/DirectShowLib-2005 to either play back a local video file or to receive (and render) the live video stream via udp using a third party DirectShow filter. The video stream uses H.265 coding and sends 1080p files.
I also have that DirectShow filter recording the live video feed to a local file for me.
When I resize the form during video playback or live video feed playback, I'm getting a device lost and need to reset it. I'm freeing all the resources, but device reset still fails unless I also destroy the graph as well. But it's used to receive my live video feed and record it.
So, problem is I would like to keep the video feed recorded without interruption by resize, move to another monitor, device lost or reset. What are my options to achieve this? We can consider converting the code to WPF/WF, purchasing a commercially available or using a free plugin to do the job, etc. Need an advice here.
Second question on the same subject, if I may. While live feed is recorded to a local file and we're playing back that live feed in the video window, we also display a time line (slider control), representing the time from the beginning of the live video feed till a present moment (which moves forward while the live feed is active). I need to give user the ability to select any previous moment in time and immediately play that part of the recorded video back, while live feed is still recorded to the same file. After reviewing a part of the recorded video, I need to know how to let user to continue watching the live feed.
I am not sure which technology we should be using to achieve that as well. I would appreciate any help.
Thank you very much.
Recording filter graphs are sensitive to unexpected state transitions and it is the assumption that recording takes place "at once" without pausing and continuations, including such as caused by necessity to reset video hardware or change format.
The typical method is to separate recording from other activity into separate graph. A dedicated recording graph would receive data produced outside and record it into file (or stream to network). Playback and presentation activity running in another graph can be flexibly reset or reconfigured as needed.
See also:
Directshow Preview Only and Capture & Preview with a single Graph

HoloLens - Capturing photo when locatable camera is in VideoMode (streaming)

I am trying to create a HoloLens application, which uses the built in WebCam to take photos and sends them to a rest interface for further face recognition. This is working well so far. To capture photos from the WebCam it needs to be in the PhotoMode.
The problem:
If I want now to present my application via live stream, the WebCam is set automatically to the VideoMode and capturing photos is not possible.
The locatable camera description https://developer.microsoft.com/en-us/windows/mixed-reality/locatable_camera_in_unity says:
"Only a single operation can occur with the camera at a time."
Since the application has to be presented to a great number of people it is absolutely essential to show it via live stream.
Does somebody have any general idea how to solve this problem, or maybe some hack to access the WebCam in PhotoMode simultaneously to the streaming?
Many thanks in advance!
This is possible if you can live with Preview Frames from the MediaCapture streams. Just start the video capture (layer on holograms if you need to), and then use the PreviewFrames as your 'photos'. This limits you to the resolution of the camera stream of course.
I was able to get this plugin working on a HoloLens. Had to use .Net instead of IL2CPP and I used 2017.4.22f1. At the very least the code shows how use MediaCapture and PreviewFrames to get a video feed from the camera for which you can grab the current frame to save as a photo. The sample doesn't do that last bit, but the bytes for the frames are being passed around, just need to make them available for your need. =)
https://github.com/VulcanTechnologies/HoloLensCameraStream

c# directshow multiple windows handling

I have problem with handling multiple video windows in directshow.
I have app in c# that captures video stream of my webcam and sends it through infinite pin tree to 2 separate renderers. When I run the app each of the renderers gets its own VideoWindow. Now when I set VideoWindow Style I can see changes only on one of them (looks like it is 2nd renderer window). Secound window is not effected at all. What should I do to access both of them? There is only one graph to build entire thing. Is there a way to reference videowindow by the renderer not by the graph? I was looking around web but there is nothing thats was able to point me in to good direction.

Save Kinect's color camera video stream in to .avi video

I want to save the video streams that is captured by Kinect's Color camera to .avi format video, I tried many ways of doing this but nothing was succeeded. Has anyone successfully done this? I'm using Kinect for Windows SDK and WFP for application development
I guess the easiest workaround would be to use a screen capture software like http://camstudio.org/.
There is also post with the same question her:
Kinect recording a video in C# WPF
As far as I understand you need to to save the single frames delivered by the kinect by into a video file. This post should explain how to do it How to render video from raw frames in WPF?.
You can use the AVIFile Windows API using interop:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd756808(v=vs.85).aspx
or you can use a wrapper like this one, done by Corina John
http://www.codeproject.com/Articles/7388/A-Simple-C-Wrapper-for-the-AviFile-Library

Directshow recording/preview problem

I have a project where I need to record a video using DirectShow from a webcam, but I need to be able to stop recording while the preview continues to run.
I am using WPFMediaKit
http://wpfmediakit.codeplex.com/
The problem is that when I record a video the pause function also pauses the preview pane in the application
I am new to DirectShow, any suggestions how is can address this issue or a solution
Thank you very much.
P.S I use C# & WPF
I don't know about the WPFMediaKit, but basically when you want to start/stop recording while keeping the preview, you will need two graphs, and something to connect between those graphs. Take a look at the pdf document at the GMFBridge page.
If you can accept a momentary pause in preview when you start/stop recording and don't want to use something like a 2 graph GMFBridge approach, you can disconnect either the capture pin on the video capture source filter (assuming you are using separate preview and a capture pins from your source filter) or disconnect the File Writer chain portion of your capture sub-graph.
The issue here is the filtergraph must be paused before changes can be made to its topology, so you'd need to:
Pause Graph
Disconnect or Reconnect File Writer chain
Resume Graph
In my experience the temporary pause is not very noticeable.
Please use StreamControl method of ICaptureGraphBuilder2, it provides you to control any filter in your Graph individually.

Categories

Resources