Media​Transcoder 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// You can use this class in JavaScript.
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 MediaTranscoder()Public Sub New()// You can use this method in JavaScript.

Properties

AlwaysReencode 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// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

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

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 : PlatForm::Boolean HardwareAccelerationEnabled { get; set; }public bool HardwareAccelerationEnabled { get; set; }Public ReadWrite Property HardwareAccelerationEnabled As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

Set to true if enabled, otherwise false.

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 TimeSpan// You can use this property in JavaScript.
Value
TimeSpan TimeSpan TimeSpan TimeSpan

A TimeSpan structure that contains the time interval.

See Also

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 TimeSpan// You can use this property in JavaScript.
Value
TimeSpan TimeSpan TimeSpan TimeSpan

A TimeSpan structure that contains the time interval.

See Also

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 MediaVideoProcessingAlgorithm// You can use this property in JavaScript.

Methods

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

Adds the specified audio effect.

public : void AddAudioEffect(PlatForm::String activatableClassId)public void AddAudioEffect(String activatableClassId)Public Function AddAudioEffect(activatableClassId As String) As void// You can use this method in JavaScript.
Parameters
activatableClassId
PlatForm::String String String String

The identifier of the audio effect.

See Also

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(PlatForm::String activatableClassId, bool 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// You can use this method in JavaScript.
Parameters
activatableClassId
PlatForm::String String String String

The identifier of the audio effect.

effectRequired
bool Boolean Boolean Boolean

Indicates whether the audio effect is required.

configuration
IPropertySet IPropertySet IPropertySet IPropertySet

Configuration properties for the audio effect.

See Also

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

Adds the specified video effect.

public : void AddVideoEffect(PlatForm::String activatableClassId)public void AddVideoEffect(String activatableClassId)Public Function AddVideoEffect(activatableClassId As String) As void// You can use this method in JavaScript.
Parameters
activatableClassId
PlatForm::String String String String

The identifier of the video effect.

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);
    }
See Also

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(PlatForm::String activatableClassId, bool 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// You can use this method in JavaScript.
Parameters
activatableClassId
PlatForm::String String String String

The identifier of the video effect.

effectRequired
bool Boolean Boolean Boolean

Indicates whether the video effect is required.

configuration
IPropertySet IPropertySet IPropertySet IPropertySet

Configuration properties for the video effect.

See Also

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

Removes all audio and video effects from the transcode session.

public : void ClearEffects()public void ClearEffects()Public Function ClearEffects() As void// You can use this method in JavaScript.

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 )// You can use this method in JavaScript.
Parameters
destination
IStorageFile IStorageFile IStorageFile IStorageFile

The destination file.

Returns
See Also

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 )// You can use this method in JavaScript.
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

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 )// You can use this method in JavaScript.
Parameters
source
IRandomAccessStream IRandomAccessStream IRandomAccessStream IRandomAccessStream

The source stream.

source cannot be a InMemoryRandomAccessStream or other writeable stream.

Returns

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

Remarks

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

See Also