MediaTranscoder MediaTranscoder MediaTranscoder MediaTranscoder Class

Transcodes audio and video files.

Syntax

Declaration

public sealed class MediaTranscoderpublic sealed class MediaTranscoderPublic NotInheritable Class MediaTranscoderpublic sealed class MediaTranscoder

Remarks

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

Constructors summary

Creates a new instance of the MediaTranscoder class.

Properties summary

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

Specifies whether hardware acceleration is enabled.

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

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

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

Methods summary

Adds the specified audio effect.

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

Adds the specified video effect.

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

Removes all audio and video effects from the transcode session.

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

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

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

Constructors

  • MediaTranscoder()
    MediaTranscoder()
    MediaTranscoder()
    MediaTranscoder()

    Creates a new instance of the MediaTranscoder class.

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

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

    Property Value

    • bool
      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 bool HardwareAccelerationEnabled { get; set; }public bool HardwareAccelerationEnabled { get; set; }Public ReadWrite Property HardwareAccelerationEnabled As boolpublic bool HardwareAccelerationEnabled { get; set; }

    Property Value

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

    Property Value

  • 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; }

    Property Value

  • 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; }

    Property Value

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.

  • 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

      Configuration properties for the audio effect.

  • 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.

    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

      Configuration properties for the video effect.

  • 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()
  • 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

    Returns

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

  • 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

    Returns

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

  • 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

    Returns

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

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

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.Media.Transcoding.dll