How to start and stop the encoding?
You should start the MWriter object with the ObjectStart method to start the encoding process in MPlatform SDK. You should use a source object as a parameter in the method:
myWriter.ObjectStart(myLive);
And to stop the encoding in MPlatform SDK, you should close the object:
myWriter.ObjectClose();
As for MFormats SDK, the encoding starts with the 1st MFFrame object you put into the MFWriter object using the ReceiverFramePut method. And it stops with the WriterClose method:
myWriter.WriterClose(1); // to close the object asynchronously
How to switch encoding to another file?
While the encoding process is running, you can switch to the next file manually at any moment with WriterNameSet method (for MWriter in MPlatform SDK) or with WriterSet method (for MFWriter in MFormats SDK). Both methods have parameters for a destination path and for encoding configuration. So if you change any (or both) these parameters, they are implemented for the next file encoding.
myWriter.WriterSet("@"c:\test.mpg", @" format='mpeg' video::codec='mpeg2video' video::b='6M' audio::codec='mp2'")
With MPlatform If you use an empty string as a destination, then output file name is [yourOriginalName] and a suffix with an index of the switch, in case of MFormats you have to specify new file name each time when you are switching the file.
If you use an empty string as encoding configuration, then the same encoding configuration is used.
How to limit encoding process in time?
You can set a maximal duration for encoding with "max_duration" property set to the desired interval in seconds with the PropsSet method.
For example, to create files with 30 seconds duration:
(myWriter as IMProps).PropsSet("max_duration", "30");
After 30 seconds the encoding is still running and it splits captured video into 30-seconds chunks. The output file name, in this case, is [yourOriginalName] and a suffix with an index of the switch (for example, "_0001"). This property is available for MPlatform SDK only.
How to limit an amount of switchings?
To limit the amount of switching, for example, to get the exact number of chunks, you should specify "max_switch_count" property.
For example, to stop encoding after just 1 file is captured you should set:
(myWriter as IMProps).PropsSet("max_switch_count", "1");
This property is available for MPlatform SDK only.
How to change a name of encoded file?
While encoding the recorded file is locked by the system, so you can't rename it. But once the encoding is over, the file is unlocked and you can rename it with system tools (like .Net components). To catch a moment when the file is unlocked, you can use OnEventSafe event (or a callback in C++) and listen to "file-close-info" event. The moment the event is raised you can get all the file information as parameters:
_mainWriter.OnEventSafe += MainWriter_OnEventSafe; void MainWriter_OnEvent(string bsChannelId, string bsEventName, string bsEventParam, object pEventObject) { if (bsEventName != "file-close-info") { // rename your file } }
How to pause for a certain period of time?
There is a WriterSkip method for the MWriter object in MPlatform SDK, with which you can pause the encoding.
myWriter.WriterSkip(10.0);
To pause the encoding in order to resume it manually you should call
myWriter.WriterSkip(0.0);
and to resume the encoding, you should call the ObjectStart method:
myWriter.ObjectStart(mySource);
With MFormats SDK you can control each frame processed by the MFWriter object, so pause and resume the encoding is operated manually.