Search code examples
c#audioazurenaudioazure-media-services

Trimming an AAC audio file using C# on Azure


I need to take an .aac audio file (Advanced Audio Coding), and programmatically extract a 10 second clip from the middle into a new .aac file using C# from a Windows Azure worker roll.

I found this article by Mark Heath which explains how a WAV file can be trimmed using NAudio, but I'm not sure how I'd do the same for an AAC file, decoding and encoding the file will lower the quality right?

I also came across Azure Media Services but I'm also struggling to see if that is anything like what I need, it looks like it might not support trimming audio.

I found the MediaTranscoder class available in windows store apps which might be able to do what I want (see this sample project that can trim videos) but can I access this API from an azure worker roll, and could it do what I want if I could?


Solution

  • Please begin with the overview of the service at http://www.windowsazure.com/en-us/develop/media-services/, get familiar with how to upload assets and create encode jobs. In your case, you would need to download the sample code, build and run it.

    Then, for trimming, you would submit jobs where the preset to the Windows Azure Media Encoder would specify your time interval as a , for example:

    <Sources>
      <Source
        AudioStreamIndex="0">
        <Clips>
          <Clip
            StartTime="00:00:00"
            EndTime="00:00:09.9740000" />
        </Clips>
        <CaptionFiles />
      </Source>
    </Sources>
    

    I can explain further details for exactly how to build the presets, but please also confirm that you know the exact in and out points you want to trim, in time format (HH:MM:SS.MMM)?