MediaTranscoder MediaTranscoder MediaTranscoder MediaTranscoder Class

Definition

Transcodes audio and video files.

public sealed class MediaTranscoderpublic sealed class MediaTranscoderPublic NotInheritable Class MediaTranscoderpublic sealed class MediaTranscoder
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() MediaTranscoder()

Creates a new instance of the MediaTranscoder class.

public MediaTranscoder()public New()Public Sub New()public MediaTranscoder()
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Properties

AlwaysReencode AlwaysReencode AlwaysReencode AlwaysReencode

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

public bool AlwaysReencode { get; set; }public bool AlwaysReencode { get; set; }Public ReadWrite Property AlwaysReencode As boolpublic bool AlwaysReencode { get; set; }
Value
bool bool bool bool

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

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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 HardwareAccelerationEnabled

Specifies whether hardware acceleration is enabled.

public bool HardwareAccelerationEnabled { get; set; }public bool HardwareAccelerationEnabled { get; set; }Public ReadWrite Property HardwareAccelerationEnabled As boolpublic bool HardwareAccelerationEnabled { get; set; }
Value
bool bool bool bool

Set to true if enabled, otherwise false.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

TrimStartTime 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 TimeSpanpublic TimeSpan TrimStartTime { get; set; }
Value
TimeSpan TimeSpan TimeSpan TimeSpan

A TimeSpan structure that contains the time interval.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

TrimStopTime 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 TimeSpanpublic TimeSpan TrimStopTime { get; set; }
Value
TimeSpan TimeSpan TimeSpan TimeSpan

A TimeSpan structure that contains the time interval.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

VideoProcessingAlgorithm 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 MediaVideoProcessingAlgorithmpublic MediaVideoProcessingAlgorithm VideoProcessingAlgorithm { get; set; }
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Methods

AddAudioEffect(String) 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 voidpublic void AddAudioEffect(String activatableClassId)
Parameters
activatableClassId
System.String System.String System.String System.String

The identifier of the audio effect.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

AddAudioEffect(String, Boolean, IPropertySet) 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 voidpublic void AddAudioEffect(String activatableClassId, Boolean effectRequired, IPropertySet configuration)
Parameters
activatableClassId
System.String System.String System.String System.String

The identifier of the audio effect.

effectRequired
System.Boolean System.Boolean System.Boolean System.Boolean

Indicates whether the audio effect is required.

configuration
IPropertySet IPropertySet IPropertySet IPropertySet

Configuration properties for the audio effect.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

AddVideoEffect(String) 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 voidpublic void AddVideoEffect(String activatableClassId)
Parameters
activatableClassId
System.String System.String System.String System.String

The identifier of the video effect.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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) 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 voidpublic void AddVideoEffect(String activatableClassId, Boolean effectRequired, IPropertySet configuration)
Parameters
activatableClassId
System.String System.String System.String System.String

The identifier of the video effect.

effectRequired
System.Boolean System.Boolean System.Boolean System.Boolean

Indicates whether the video effect is required.

configuration
IPropertySet IPropertySet IPropertySet IPropertySet

Configuration properties for the video effect.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

ClearEffects() ClearEffects() ClearEffects() ClearEffects()

Removes all audio and video effects from the transcode session.

public void ClearEffects()public void ClearEffects()Public Function ClearEffects() As voidpublic void ClearEffects()
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

PrepareFileTranscodeAsync(IStorageFile, IStorageFile, MediaEncodingProfile) 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 )public IAsyncOperation<PrepareTranscodeResult> PrepareFileTranscodeAsync(IStorageFile source, IStorageFile destination, MediaEncodingProfile profile)
Parameters
destination
IStorageFile IStorageFile IStorageFile IStorageFile

The destination file.

Returns

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

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

PrepareMediaStreamSourceTranscodeAsync(IMediaSource, IRandomAccessStream, MediaEncodingProfile) 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 )public IAsyncOperation<PrepareTranscodeResult> PrepareMediaStreamSourceTranscodeAsync(IMediaSource source, IRandomAccessStream destination, MediaEncodingProfile profile)
Parameters
source
IMediaSource IMediaSource IMediaSource IMediaSource

The media source to perform the transcode operation on.

destination
IRandomAccessStream IRandomAccessStream IRandomAccessStream IRandomAccessStream

The destination stream for the transcoded media data.

Returns

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

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

PrepareStreamTranscodeAsync(IRandomAccessStream, IRandomAccessStream, MediaEncodingProfile) 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 )public IAsyncOperation<PrepareTranscodeResult> PrepareStreamTranscodeAsync(IRandomAccessStream source, IRandomAccessStream destination, MediaEncodingProfile profile)
Parameters
source
IRandomAccessStream IRandomAccessStream IRandomAccessStream IRandomAccessStream

The source stream.

source cannot be a InMemoryRandomAccessStream or other writeable stream.

Returns

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

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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);