how to extract and convert audio file formats
来源:互联网 发布:手机时钟软件 编辑:程序博客网 时间:2024/06/06 01:19
This is an All-In-One Code Framework (http://1code.codeplex.com) sample to be published as KB. The sample package and the KBdraft are attached. The samples in the project are featured by:
1) Sample Source: The samples are refined out of CSS developer supports forcustomers. You can think of the samples as a collection of most frequentlyasked coding scenarios in contrast with FAQs.
2) Three Languages: Almost all samples are provided in three popularprogramming languages: VC# and VB.NET when applicable.
3) All-In-One: All sample for all Microsoft development techniques are in onesolution.
4) Simple build and run experience.
How to extract and convertaudio file formats
This article describes anAll-In-One Code Framework sample that is available for download. The sample demonstrates how to extract and convert audiofile formats, which include wav, mp3 and mp4 files.
The sample is used to extractmusic file formats. We usually play music with Windows Media Player or othermusic-playing software. If we find our favorite music clip, we can use thefunction of this sample to extract it and convert it into another file format.All technology mentioned above is based on Expression Encoder SDK 4.0. When youinstall Expression Encoder 4.0, you can use Visual Studio 2010 to add areference to it. In this way, you don't have to install the SDK installationkits individually.
The sample uses ExpressionEncoder SDK 4 to output *.mp4 or *.wma file. The .mp3 audio format is currentlynot supported as output format in Expression Encoder 4.
Difficulty Level
Medium
Technicaloverview
1. Usefollowing helper function to cut the audio file from startpoint to endpoint,and output the clip as the selected audio format.
public static string ExtractAudio(string sourceAudioFile, string outputDirectory,
OutputAudioType outputAudioType, double startpoint, double endpoint)
{
using (Job job = new Job())
{
MediaItem src = new MediaItem(sourceAudioFile);
switch (outputAudioType)
{
case OutputAudioType.MP4:
src.OutputFormat = new MP4OutputFormat();
src.OutputFormat.AudioProfile = new AacAudioProfile();
src.OutputFormat.AudioProfile.Codec = AudioCodec.AAC;
src.OutputFormat.AudioProfile.BitsPerSample = 24;
break;
case OutputAudioType.WMA:
src.OutputFormat = new WindowsMediaOutputFormat();
src.OutputFormat.AudioProfile = new WmaAudioProfile();
src.OutputFormat.AudioProfile.Bitrate = new VariableConstrainedBitrate(128, 192);
src.OutputFormat.AudioProfile.Codec = AudioCodec.WmaProfessional;
src.OutputFormat.AudioProfile.BitsPerSample = 24;
break;
}
TimeSpan spanStart = TimeSpan.FromMilliseconds(startpoint);
src.Sources[0].Clips[0].StartTime = spanStart;
TimeSpan spanEnd = TimeSpan.FromMilliseconds(endpoint);
src.Sources[0].Clips[0].EndTime = spanEnd;
job.MediaItems.Add(src);
job.OutputDirectory = outputDirectory;
job.Encode();
return job.MediaItems[0].ActualOutputFileFullPath;
}
}
2. Use the Windows Media Player control to play thesource audio file. The following MSDN article introduces how to embed theWindows Media Player ActiveX control in a Windows Form. http://msdn.microsoft.com/en-us/library/dd562851.aspx
For more information about how to create and deploy thesample application, see the Readme.txt file that is included in the downloadpackage.
Technologycategory
Network
Languages
Language
Project Name
Visual C#
CSExtractAudioFile
Visual Basic.NET
VBExtractAudioFile
Prerequisites
Thissample application was created by using Visual Studio 2010, .NETFramework 4 and Microsoft Expression Encoder 4.
References
Expression Encoder SDKProgramming Reference
http://msdn.microsoft.com/en-us/library/ff396833(v=Expression.40).aspx
Microsoft Expression Encoder 4FAQ
http://social.expression.microsoft.com/Forums/en/encoder/thread/3eabf903-b49f-4f92-b508-f28a795d6c90
- how to extract and convert audio file formats
- raw file(audio file format) How to convert endianness
- Audio File Formats FAQ
- How to extract the file *.tar.bz2?
- how to extract code of apk file
- convert video/audio file to audio format with ffmpeg
- How to Convert An audio From m4a to pcm
- Extract audio from video file.
- how to convert xacro file to urdf file?
- How to convert between TDes8 and TDes16
- How to convert a latex to pdf file
- How to Create and Optimize Sprite Sheets in Cocos2D with Texture Packer and Pixel Formats
- How to load FIBITMAP and convert it to HBITMAP
- How to use plugin audio codecs in OpenH323 and OPAL
- How to compress and decompress file
- How to find code and file
- How to read DBTABLOG and Convert DBTABLOG- LOGDATA
- How can I convert NSDictionary to NSData and vice versa?
- 快速简单删除SVN信息的方法
- eclipse中打点不出来提示
- Mei Liang demos OneCode in Channel 9
- sql语句-删除数据库所有表里的数据
- 关于linux驱动(应用)程序头文件使用
- how to extract and convert audio file formats
- 如何提高PHP编程效率
- 33.VC(custom)-线程同步和循环锁
- sql union用法
- 在ADO数据库连接中遇到的类型转换
- 一个DB类,MYSQL
- 验车经历
- 博客第一帖
- nutch1.2 fetcher类解析