Media​Transcoder Media​Transcoder Media​Transcoder Class

Definition

Transcodes audio and video files.

public sealed class MediaTranscoder : IMediaTranscoder, IMediaTranscoder2public sealed class MediaTranscoder : IMediaTranscoder, IMediaTranscoder2Public NotInheritable Class MediaTranscoder Implements IMediaTranscoder, IMediaTranscoder2
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

For how-to guidance on transcoding media files, see Transcode media files.

Constructors

MediaTranscoder() MediaTranscoder() MediaTranscoder()

Creates a new instance of the MediaTranscoder class.

public MediaTranscoder()public MediaTranscoder()Public Sub New()
Attributes

Properties

AlwaysReencode AlwaysReencode AlwaysReencode

Specifies whether the media transcoder always re-encodes the source.

public PlatForm::Boolean AlwaysReencode { get; set; }public bool AlwaysReencode { get; set; }Public ReadWrite Property AlwaysReencode As bool
Value
bool bool bool

true if the media transcoder always re-encodes the source; otherwise false. The default value is false.

Attributes

Remarks

If this property is false, the media transcoder remuxes the source without re-encoding, when possible. If the property is true, the media transcoder always re-encodes the source. The default value is false.

HardwareAccelerationEnabled HardwareAccelerationEnabled HardwareAccelerationEnabled

Specifies whether hardware acceleration is enabled.

public PlatForm::Boolean HardwareAccelerationEnabled { get; set; }public bool HardwareAccelerationEnabled { get; set; }Public ReadWrite Property HardwareAccelerationEnabled As bool
Value
bool bool bool

Set to true if enabled, otherwise false.

Attributes

TrimStartTime TrimStartTime TrimStartTime

Gets or sets the time interval to trim from the start of the output.

public TimeSpan TrimStartTime { get; set; }public TimeSpan TrimStartTime { get; set; }Public ReadWrite Property TrimStartTime As TimeSpan
Value
TimeSpan TimeSpan TimeSpan

A TimeSpan structure that contains the time interval.

Attributes
See Also

TrimStopTime TrimStopTime TrimStopTime

Gets or sets the time interval to trim from the end of the output.

public TimeSpan TrimStopTime { get; set; }public TimeSpan TrimStopTime { get; set; }Public ReadWrite Property TrimStopTime As TimeSpan
Value
TimeSpan TimeSpan TimeSpan

A TimeSpan structure that contains the time interval.

Attributes
See Also

VideoProcessingAlgorithm VideoProcessingAlgorithm VideoProcessingAlgorithm

Gets or sets the video processing algorithm which will be used for transcoding.

public MediaVideoProcessingAlgorithm VideoProcessingAlgorithm { get; set; }public MediaVideoProcessingAlgorithm VideoProcessingAlgorithm { get; set; }Public ReadWrite Property VideoProcessingAlgorithm As MediaVideoProcessingAlgorithm
Attributes

Methods

AddAudioEffect(String) AddAudioEffect(String) AddAudioEffect(String)

Adds the specified audio effect.

public void AddAudioEffect(String activatableClassId)public void AddAudioEffect(String activatableClassId)Public Function AddAudioEffect(activatableClassId As String) As void
Parameters
activatableClassId
System.String System.String System.String

The identifier of the audio effect.

Attributes

AddAudioEffect(String, Boolean, IPropertySet) AddAudioEffect(String, Boolean, IPropertySet) AddAudioEffect(String, Boolean, IPropertySet)

Adds the specified audio effect with configuration properties, and indicates whether the effect is required.

public void AddAudioEffect(String activatableClassId, Boolean effectRequired, IPropertySet configuration)public void AddAudioEffect(String activatableClassId, Boolean effectRequired, IPropertySet configuration)Public Function AddAudioEffect(activatableClassId As String, effectRequired As Boolean, configuration As IPropertySet) As void
Parameters
activatableClassId
System.String System.String System.String

The identifier of the audio effect.

effectRequired
System.Boolean System.Boolean System.Boolean

Indicates whether the audio effect is required.

configuration
IPropertySet IPropertySet IPropertySet

Configuration properties for the audio effect.

Attributes

AddVideoEffect(String) AddVideoEffect(String) AddVideoEffect(String)

Adds the specified video effect.

public void AddVideoEffect(String activatableClassId)public void AddVideoEffect(String activatableClassId)Public Function AddVideoEffect(activatableClassId As String) As void
Parameters
activatableClassId
System.String System.String System.String

The identifier of the video effect.

Attributes

Remarks

Examples

The following example adds a video effect to the transcoder.


function doTranscode() {
        // Clear any existing effects.
        transcoder.clearEffects;
        // Add video effect.
        transcoder.addVideoEffect(videoEffect);
        // Add audio effect.
        transcoder.addAudioEffect(audioEffect);
        // Set start and stop times for trimming.
        transcoder.trimStartTime(1000);
        transcoder.trimStopTime(9000);
        // Always reencode the source
        transcoder.alwaysReencode = true;

        return transcoder.prepareFileTranscodeAsync(source, destination, profile);
    }

AddVideoEffect(String, Boolean, IPropertySet) AddVideoEffect(String, Boolean, IPropertySet) AddVideoEffect(String, Boolean, IPropertySet)

Adds the specified video effect with configuration properties and indicates whether the effect is required.

public void AddVideoEffect(String activatableClassId, Boolean effectRequired, IPropertySet configuration)public void AddVideoEffect(String activatableClassId, Boolean effectRequired, IPropertySet configuration)Public Function AddVideoEffect(activatableClassId As String, effectRequired As Boolean, configuration As IPropertySet) As void
Parameters
activatableClassId
System.String System.String System.String

The identifier of the video effect.

effectRequired
System.Boolean System.Boolean System.Boolean

Indicates whether the video effect is required.

configuration
IPropertySet IPropertySet IPropertySet

Configuration properties for the video effect.

Attributes

ClearEffects() ClearEffects() ClearEffects()

Removes all audio and video effects from the transcode session.

public void ClearEffects()public void ClearEffects()Public Function ClearEffects() As void
Attributes

PrepareFileTranscodeAsync(IStorageFile, IStorageFile, MediaEncodingProfile) PrepareFileTranscodeAsync(IStorageFile, IStorageFile, MediaEncodingProfile) PrepareFileTranscodeAsync(IStorageFile, IStorageFile, MediaEncodingProfile)

Asynchronously initializes the trancode operation on the specified file and returns a PrepareTranscodeResult object which can be used to start the transcode operation.

public IAsyncOperation<PrepareTranscodeResult> PrepareFileTranscodeAsync(IStorageFile source, IStorageFile destination, MediaEncodingProfile profile)public IAsyncOperation<PrepareTranscodeResult> PrepareFileTranscodeAsync(IStorageFile source, IStorageFile destination, MediaEncodingProfile profile)Public Function PrepareFileTranscodeAsync(source As IStorageFile, destination As IStorageFile, profile As MediaEncodingProfile) As IAsyncOperation( Of PrepareTranscodeResult )
Parameters
source
IStorageFile IStorageFile IStorageFile

The source file.

destination
IStorageFile IStorageFile IStorageFile

The destination file.

profile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The profile to use for the operation.

Returns

When this method completes, a PrepareTranscodeResult object is returned which can be used to start the transcode.

Attributes
See Also

PrepareMediaStreamSourceTranscodeAsync(IMediaSource, IRandomAccessStream, MediaEncodingProfile) PrepareMediaStreamSourceTranscodeAsync(IMediaSource, IRandomAccessStream, MediaEncodingProfile) PrepareMediaStreamSourceTranscodeAsync(IMediaSource, IRandomAccessStream, MediaEncodingProfile)

Asynchronously initializes the trancode operation on the specified media source and returns a PrepareTranscodeResult object which can be used to start the transcode operation.

public IAsyncOperation<PrepareTranscodeResult> PrepareMediaStreamSourceTranscodeAsync(IMediaSource source, IRandomAccessStream destination, MediaEncodingProfile profile)public IAsyncOperation<PrepareTranscodeResult> PrepareMediaStreamSourceTranscodeAsync(IMediaSource source, IRandomAccessStream destination, MediaEncodingProfile profile)Public Function PrepareMediaStreamSourceTranscodeAsync(source As IMediaSource, destination As IRandomAccessStream, profile As MediaEncodingProfile) As IAsyncOperation( Of PrepareTranscodeResult )
Parameters
source
IMediaSource IMediaSource IMediaSource

The media source to perform the transcode operation on.

destination
IRandomAccessStream IRandomAccessStream IRandomAccessStream

The destination stream for the transcoded media data.

profile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The profile to use for the operation.

Returns

When this method completes, a PrepareTranscodeResult object is returned which can be used to start the transcode.

Attributes

PrepareStreamTranscodeAsync(IRandomAccessStream, IRandomAccessStream, MediaEncodingProfile) PrepareStreamTranscodeAsync(IRandomAccessStream, IRandomAccessStream, MediaEncodingProfile) PrepareStreamTranscodeAsync(IRandomAccessStream, IRandomAccessStream, MediaEncodingProfile)

Asynchronously initializes the trancode operation on the specified stream and returns a PrepareTranscodeResult object which can be used to start the transcode operation.

public IAsyncOperation<PrepareTranscodeResult> PrepareStreamTranscodeAsync(IRandomAccessStream source, IRandomAccessStream destination, MediaEncodingProfile profile)public IAsyncOperation<PrepareTranscodeResult> PrepareStreamTranscodeAsync(IRandomAccessStream source, IRandomAccessStream destination, MediaEncodingProfile profile)Public Function PrepareStreamTranscodeAsync(source As IRandomAccessStream, destination As IRandomAccessStream, profile As MediaEncodingProfile) As IAsyncOperation( Of PrepareTranscodeResult )
Parameters
source
IRandomAccessStream IRandomAccessStream IRandomAccessStream

The source stream.

source cannot be a InMemoryRandomAccessStream or other writeable stream.

destination
IRandomAccessStream IRandomAccessStream IRandomAccessStream

The destination stream.

profile
MediaEncodingProfile MediaEncodingProfile MediaEncodingProfile

The profile to use for the operation.

Returns

When this method completes, a PrepareTranscodeResult object is returned which can be used to start the transcode.

Attributes

Remarks

The source parameter cannot be a InMemoryRandomAccessStream or other writeable stream.

Examples

The following example shows how to use this method to transcode a stream.

var transcoder = new Windows.Media.Transcoding.MediaTranscoder();
return transcoder.prepareStreamTranscodeAsync(sourceStream, destinationStream, profile);

See Also