AVBlocks for .NET
1.13
Audio and Video Software Development Kit
|
Provides functionality for audio and video encoding, decoding and transforming. More...
Inherits IDisposable.
Public Member Functions | |
Transcoder () | |
Creates a Transcoder object in its default state. More... | |
bool | Open () |
Initializes the Transcoder based on the specified input and desired output. More... | |
bool | Run () |
Runs an automatic transcoding. More... | |
bool | Push (int inputIndex, MediaSample inputSample) |
Pushes input data to the Transcoder. More... | |
bool | Pull (out int outputIndex, MediaSample outputSample) |
Pulls output data from the Transcoder. More... | |
void | Close () |
Closes the Transcoder. More... | |
bool | Flush () |
Flushes the data buffered in the Transcoder to the output. More... | |
bool | Stop (int inputIndex) |
Tells the Transcoder that there's no more data for the specified input socket. More... | |
void | Dispose () |
Disposes the Transcoder and reclaims the resources used by the object. More... | |
Properties | |
IList< MediaSocket > | Inputs [get] |
A modifiable collection of MediaSocket objects which describe the input data of the Transcoder. More... | |
IList< MediaSocket > | Outputs [get] |
A modifiable collection of MediaSocket objects which describe the output data of the Transcoder. More... | |
bool | AutoConnect [get, set] |
Specifies whether the Transcoder automatically connects input to output pins when opened. More... | |
bool | AllowDemoMode [get, set] |
Specifies whether the Transcoder allows demo mode (unlicensed transcoding). More... | |
ErrorInfo | Error [get] |
The error information for the last transcoder operation. More... | |
Events | |
EventHandler < TranscoderProgressEventArgs > | OnProgress |
This event is raised periodically by the Transcoder to report transcoding progress. More... | |
EventHandler < TranscoderStatusEventArgs > | OnStatus |
This event is raised by the Transcoder to report the status of current operation. More... | |
EventHandler < TranscoderContinueEventArgs > | OnContinue |
This event is raised by the Transcoder to give the user code a chance to stop the transcoding process started by Transcoder.Run. More... | |
Provides functionality for audio and video encoding, decoding and transforming.
Transcoder | ( | ) |
Creates a Transcoder object in its default state.
When the Transcoder object is not needed anymore it should be disposed in order to deterministically reclaim the allocated resources.
void Close | ( | ) |
Closes the Transcoder.
When closed it can neither accept, nor process data.
Transcoder.Inputs and Transcoder.Outputs are not modified.
void Dispose | ( | ) |
Disposes the Transcoder and reclaims the resources used by the object.
bool Flush | ( | ) |
Flushes the data buffered in the Transcoder to the output.
This method can be used only in write mode.
bool Open | ( | ) |
Initializes the Transcoder based on the specified input and desired output.
If this method succeeds the Transcoder is ready to process input data.
The data flow may be driven by one of the following methods:
Push() - The caller pushes input data to the Transcoder. The Transcoder writes the output data to a file or user stream.
Pull() - The caller pulls output data from the Transcoder. The Transcoder reads the input data from a file or user stream.
Push() and Pull() - The caller both pushes and pulls data to/from the Transcoder.
Run() - The caller waits for the transcoding to finish. The Transcoder automatically reads the input data from a file or user stream and writes the output to a file or user stream. The process runs until the input data is depleted or there's a processing error.
However not all stream types can be used in push or pull mode. See related page "Transcoder Input/Output Model" for more info.
References Transcoder.Inputs, and Transcoder.Outputs.
bool Pull | ( | out int | outputIndex, |
MediaSample | outputSample | ||
) |
Pulls output data from the Transcoder.
outputIndex | Returns the index of the output socket to which the data belongs. |
outputSample | The MediaSample object receives the output data. |
In order to use the pull mode the output sockets must not have an associated file or user stream. If the transcoder operates in the hybrid push/pull mode it will return TranscoderError.InputNeeded when there's no available output. In this case Push() must be called to supply input data to the transcoder.
Warning: This method is not thread-safe (as all other functions in AVBlocks). It cannot be called simultaneously from multiple threads. You must implement your own synchronization if the method will be called from multiple threads.
bool Push | ( | int | inputIndex, |
MediaSample | inputSample | ||
) |
Pushes input data to the Transcoder.
inputIndex | Specifies the index of the input socket whose data is pushed to the Transcoder. |
inputSample | A MediaSample object that contains the input data. When this method returns successfully inputSample contains no valid data. |
In order to use this method the input socket must not have an associated file or user stream. If the Transcoder operates in the hybrid push/pull mode it will return TranscoderError.BufferFull when it cannot accept the input. In this case Pull() must be called to retrieve the available output.
NOTE: The input sample can contain an image like bmp, png or jpeg. This makes it possible to create a video from one or more images with any duration. The start time of each input sample must be set explicitly and must increase for each successive sample.
Warning: This method is not thread-safe (as all other functions in AVBlocks). It cannot be called simultaneously from multiple threads. You must implement your own synchronization if the method will be called from multiple threads.
References MediaSample.Buffer, and MediaBuffer.DataSize.
bool Run | ( | ) |
Runs an automatic transcoding.
false when there's a transcoding error or the Run() method cannot be used with the specified inputs and outputs.
In order to use the run mode all input and output sockets must be associated with files or user streams. This method returns when the transcoding is finished because there's no more input data to process or when there's an error.
NOTE: The input socket can specify an image file in which case the output video contains a single frame. A single frame video (MPEG-2) can be used as a background in DVD-Video authoring. For generating a custom video from many images see Push().
bool Stop | ( | int | inputIndex | ) |
Tells the Transcoder that there's no more data for the specified input socket.
inputIndex | Specifies the index of the input socket for which there's no more data. |
If the last input socket is stopped the Transcoder flushes its internal buffers to the output. This method can be used only in write mode.
|
getset |
Specifies whether the Transcoder allows demo mode (unlicensed transcoding).
If true a demo watermark is applied when a required feature (codec/format) is not licensed. If false the Transcoder returns an AVBlocksError.UnlicensedFeature error instead of applying the demo watermark when a required feature is not licensed.
|
getset |
Specifies whether the Transcoder automatically connects input to output pins when opened.
Only pins that have their ID property equal to PinConnection.Auto participate in the automatic connection. Those pins that are sucessfully connected have their ID property set to a unique value that is greater than PinConnection.Auto.
|
get |
A modifiable collection of MediaSocket objects which describe the input data of the Transcoder.
Each socket in the collection represents an input point - it can be a container with one or more streams or just an elementary stream.
The default value of this property is an empty collection which can be modified but it cannot be replaced.
Referenced by Transcoder.Open().
|
get |
A modifiable collection of MediaSocket objects which describe the output data of the Transcoder.
Each socket in the collection describes an output point - it can be a container with one or more streams or just an elementary stream.
The default value of this property is an empty collection which can be modified but it cannot be replaced.
Referenced by Transcoder.Open().
EventHandler<TranscoderContinueEventArgs> OnContinue |
This event is raised by the Transcoder to give the user code a chance to stop the transcoding process started by Transcoder.Run.
When instructed the Transcoder stops the transcoding process gracefully so that the media data processed so far is valid (playable).
This event is called as often as possible so that the user code may stop the transcoding process as soon as it is required. For this reason there should be minimal processing in this event, otherwise the overall transcoding may be slowed down.
EventHandler<TranscoderProgressEventArgs> OnProgress |
This event is raised periodically by the Transcoder to report transcoding progress.
See Transcoder.Run.
For performance reasons this event is not raised for every processed media sample. Currently it is called once for every 0.5 seconds of processed media data. This notification is intended for user interface updates.
The transcoding progress in percents is given by the properties of TranscoderProgressEventArgs:
(CurrentTime / TotalTime * 100).
The Transcoder does not guarantee that CurrentTime will ever reach TotalTime even when the transcoding completes sucessfully.
EventHandler<TranscoderStatusEventArgs> OnStatus |
This event is raised by the Transcoder to report the status of current operation.