Comments (24)
Hello
Before assiging the new sink, you must stop the live stream with a call to _ic.LiveStop().
from ic-imaging-control-samples.
Hi Mr. Stefan,
Thank you for your response, I tried this and called LiveStop() as such,
_ic.LiveStop();
MediaStreamSink aviSink = new MediaStreamSink();
however,, while this does ensure a recording, I cannot see the camera feed while recording as it freezes the display as soon as I press the record button.
I should clarify, i am building my application through a WPF, rather than winforms shown in the IC Samples.
from ic-imaging-control-samples.
Hello
I suggest, you may look at the IC Imaging Control Sample in your "Documents/IC Imaging Control 3.5" directory. There you will see, how to capture an AVI file.
You can pause the video capture with https://www.theimagingsource.com/support/documentation/ic-imaging-control-net/prop_descBaseSink_SinkModeRunning.htm. So the AVI file is created after the sink is created. If StartLive is called, no frames are saved into the file, until the SinkModerRunnink property of the MediaStreamSink is changed.
Stefan
from ic-imaging-control-samples.
I shall have a look at that. Is there any chance that there is a record program using WPF? The current examples are all WinForms.
I appreciate your help.
from ic-imaging-control-samples.
I am sorry, but there is no recording program for WPF.
I just saw in the caption you use WPF... I am so sorry, my answers are not helpful for you, because I did not understood your issue.
Now I understand. Using WPF you can not use the MediaStreamsink. But you can save the incoming frames on your own. The "Naudio" library is helpful for this. Currently I am out of office, so I do not have access to my sample library. If you mind to remember me by next week, I show you, how to use the NAudio library for MP4 / h264 capture in C#
Stefan
from ic-imaging-control-samples.
Hi Stefan
Thats totally fine, Ill have a look at the Naudio library. I would greatly appreciate your help, ill give you a message next week. Thank you once again.
Regards
KillSwitch
from ic-imaging-control-samples.
Hello Stefan,
Just reaching out to you regarding the video recording. Is there any other way you would prefer to communicate or this place ok?
Kind Regards
KillSwitch
from ic-imaging-control-samples.
Hello
Please look at the sample of #51 (comment)
Stefan
from ic-imaging-control-samples.
Hi Stefan,
Thanks for the sample. I really appreciate it. Does this method work for a WPF program?
Regards
from ic-imaging-control-samples.
Hi Stefan, Ive uploaded a sample program of what Im working with. Ive added some annotations in the code. I want the user to be able to record the video while the camera is still streaming. Im not sure how to do it from the winform app from #51 as my desired program is written in WPF. Do you have any insight into this?
Regards
KillSwitch
from ic-imaging-control-samples.
Yes, this will work with WPF too. In the sample you use is an image callback, in which you receive the image. You can additionally forward this image to be saved in to the mp4 file, as shown in the sample in #51. Simply copy the parts you need from this sample.
Stefan
from ic-imaging-control-samples.
Hi Stefan,
Thank you for your response. Unfortunately I am still confused as to what to take from your sample.
As you can see in the attached picture, I have a few buttons and a camera display. In this case, Im looking at the start recording and stop recording buttons. the image is displayed from a usercontrol I created. The select device button will trigger the capture rather than a start and stop button. Im not sure where to put what from #51,
Please excuse my experience, I am quite new to C#. Your help is very much appreciated. Please let me know if you would like to see my source code if it may assist you.
Kind Regards
KillSwitch
from ic-imaging-control-samples.
Hello
In the sample #51 in form1.cs you will find at the end:
private void SaveBufferList(String FileName)
{
MFTestSharp.H264Writer writer;
int BITRATE = 60 * 1000000;
writer = new MFTestSharp.H264Writer(FileName, _sink.OutputFrameType, (int)icImagingControl1.DeviceFrameRate, BITRATE);
writer.Begin();
for (int i = 0; i < _bufferlist.Length; i++)
{
writer.Write(_bufferlist[i]);
}
writer.End();
}
This function uses a list of IFrameQueueBuffers, that is written by the "writer" into a MP4 file.
That means for you:
The "writer" will be an attribute (varialbe) of your class. You also need a flag, that indicates, you want to capture into a videofile
private MFTestSharp.H264Writer _writer;
private bool _capturetovideo = false;
`You create and configure the writer when "Start Recording" was clicked. Also you set the _capturetovideo flag to true, so your class knows, that the frames are to be saved now:
int BITRATE = 60 * 1000000;
writer = new MFTestSharp.H264Writer(FileName, _sink.OutputFrameType, (int)icImagingControl1.DeviceFrameRate, BITRATE);
writer.Begin();
_capturetovideo = true;
In the function void DoUpdateImage(TIS.Imaging.IFrame buffer)
you add the buffer to the video file:
if( _capturetovideo )
writer.Write(buffer );
When "Stop Recording" ist clicked, you have two lines of code:
_capturetovideo = true;
_writer.End();
Since we are in a multithreaded situation here, the simple way to avoid conflicts is System.Threading.Sleep(200) between those lines. The correct way is different, but I do not want to confuse you.
You need the MFTestSharp.H264Writer stuff from the #51 sample.
Stefan
from ic-imaging-control-samples.
Hi Stefan,
Following your lead, this is what I have, I added H264Writer and the SinkListener to the code.
private void SaveBufferList(String FileName)
{
MFTestSharp.H264Writer writer;
int BITRATE = 60 * 1000000;
writer = new MFTestSharp.H264Writer(FileName, _sink.OutputFrameType, (int)_ic.DeviceFrameRate, BITRATE);
writer.Begin();
for (int i = 0; i < _bufferlist.Length; i++)
{
writer.Write(_bufferlist[i]);
}
writer.End();
}
Then, the logic for the Start Recording Dialog,
private System.Windows.Forms.SaveFileDialog SaveFileDialog1;
private void btnRecordCapture_Click(object sender, RoutedEventArgs e)
{
_capturetovideo = true;
if (_ic.DeviceValid)
{
var dialog = new SaveFileDialog();
dialog.FileName = "Capture";
dialog.DefaultExt = "avi";
var dialogresult = dialog.ShowDialog();
if (dialogresult != true)
{
SaveBufferList(SaveFileDialog1.FileName);
}
}
if (!_ic.DeviceValid)
{
MessageBox.Show("Please start capture first.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
Then the logic for Stop Recording dialog,
private void btnStopRecord_Click(object sender, RoutedEventArgs e)
{
if (_ic.DeviceValid)
{
_capturetovideo = true;
_writer1.End();
}
if (!_ic.DeviceValid)
{
MessageBox.Show("Please start capture first.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
Is this looking correct?
The thing regarding the void DoUpdateImage(TIS.Imaging.IFrame buffer)
is that the function resides in the VideoWindow.cs file, which is a separate user control. I cannot put the following, without it throwing an error.
if( _capturetovideo )
writer.Write(buffer );
Thank you very much for your time. I really do appreciate it.
from ic-imaging-control-samples.
The "SaveBufferList" function is not needed in your code. It is to show, how simple this stuff is, only.
Please read my previous answer carefully, because it tells you all, what you need to know!
Stefan
from ic-imaging-control-samples.
Hi Stefan,
Sadly I am still unable to get it to work. If you could look at my code and let me know where I've gone wrong, it would be of great help. I am desperate to get the video recording working.
MainWindowCS.txt
VideoWindowCS.txt
these files are source files behind the main window and video window. Video window is edited to include just the basics. Im still quite lost :(.
from ic-imaging-control-samples.
Where in "VideoWindow.cs" do you set "_capturetovideo" to true? Answer: Nowhere. Thus: Neither the writer is created, nor the buffers are pass to the writer.
I am pretty sure, you can figure this out on your own, because this is really basics of programming. (No offense meant.)
from ic-imaging-control-samples.
Hello
Did you figure out, why your program can not save images to the video file? You did not set the _capturetovideo variable to true in "VideoWindow.cs". Therefore nothing is captured.
I also should mention, you must call
MediaFoundationApi.Startup();
once. This can be done in the constructor of your class.
Stefan
from ic-imaging-control-samples.
Hi Stefan,
Sadly not. I have set the private bool _capturetovideo = true;
as you said, Also, I called MediaFoundationApi.Startup
in the videoWindow constructor. The problem I have found is that in private MFTestSharp.H264Writer _writer1;
in the VideoWindow.xaml.cs the _writer1 is never called. Hence, when I try to even run the camera, an error is thrown here.
if (_capturetovideo)
{
_writer1.Write(buffer);
}
Here, _writer1
is null, because it was never initialized in the videoWindow. This is why it doesn't work.
Regards
from ic-imaging-control-samples.
Hi
Here, _writer1 is null, because it was never initialized in the videoWindow. This is why it doesn't work.
So you must create the _writer1 as I showed yester.
Stefan
from ic-imaging-control-samples.
Hi,
I am sorry, I am very novice in programming (few weeks) hence I am having trouble with this.
I created the private MFTestSharp.H264Writer _writer1;
. By initialising, I assume you mean putting this in
private void DoUpdateImage(IFrame buffer)
if (_capturetovideo)
{
int BITRATE = 60 * 1000000;
_writer1 = new MFTestSharp.H264Writer(dialog.FileName, _sink.OutputFrameType, (int)_ic.DeviceFrameRate, BITRATE);
_writer1.Write(buffer);
}
Once again, my apologies for my inexperience.
from ic-imaging-control-samples.
Hi
Please analyze your code. It creates a new video file for each incoming image. Is this wanted?
Stefan
from ic-imaging-control-samples.
No, I want to create a video file, when the button is pressed.
from ic-imaging-control-samples.
I thought so.
I am sorry, but it seems, you have not even basic knowledge about programming. Please understand, that I can not teach you object oriented programming.
Stefan
from ic-imaging-control-samples.
Related Issues (20)
- Confusion about version of tisgrabber.dll HOT 3
- Framesnapsink/Framequesink HOT 3
- Noise Reduction HOT 18
- Taking images after external trigger for a fixed time HOT 13
- How to operate multiple cameras at the same time get image through python HOT 2
- Knowing when callback fails HOT 8
- Detailed trigger mode setting HOT 2
- Capture AVI program is not working HOT 12
- Activate/deactivate external trigger using python script HOT 4
- Exception: A set operation on a VCDProperty object failed HOT 10
- IC_StartLive fail HOT 3
- Cannot get Map Strings for Strobe Mode in python HOT 18
- Get crashed on create MediaStreamSink object in C# in .net core 7 HOT 2
- Web browser stream HOT 5
- Getting the exposure time HOT 3
- IC Imaging source upgrade to 3.5 from 3.4 HOT 1
- Ic imaging control 3.5 HOT 3
- tisfrabber LoadDeviceStateFromFile() and SnapImage HOT 1
- Python (tisgrabber): interaction with camera livestream IC_StartLive HOT 5
- Wondering if it's possible to make the video window scrollable in python HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ic-imaging-control-samples.