IT Community - Software Programming, Web Development and Technical Support

Encoding WMV file in C# .Net

This is a discussion on Encoding WMV file in C# .Net within the C# Programming forums, part of the Software Development category; Objective: Encoding WMV files for streaming in C# .NET Steps: 1. Create a windows class library project. 2. You should ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 07-15-2007, 11:49 PM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Encoding WMV file in C# .Net

Objective: Encoding WMV files for streaming in C# .NET

Steps:

1. Create a windows class library project.
2. You should install windows Media Encoder.
3. Add the windows Media Encoder component reference.
4. Copy and paste the below method inside the class file.

If You call this method with inputfilename,outputFilename,encodingProfileName, You will get the encoded WMV file.


private void DoEncode(string inputFileName, string outputFilename, string encodingProfileName)
{
IWMEncSourceGroupCollection srcGrpColl;
IWMEncSourceGroup srcGrp;
IWMEncSource srcAud;
IWMEncVideoSource2 srcVid;
IWMEncFile2 outFile;
IWMEncProfile2 pro;

if (File.Exists(inputFileName) && File.Exists(encodingProfileName)))
{
encoder = new WMEncoder();

srcGrpColl = encoder.SourceGroupCollection;
srcGrp = srcGrpColl.Add("WmvSrc");

srcAud = srcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
srcVid = (IWMEncVideoSource2)srcGrp.AddSource(WMENC_SOURCE_ TYPE.WMENC_VIDEO);
srcAud.SetInput(inputFileName, "", "");
srcVid.SetInput(inputFileName, "", "");

pro = new WMEncProfile2();
pro.LoadFromFile(inputFileName);
srcGrp.set_Profile(pro);

outFile = (IWMEncFile2)encoder.File;
outFile.LocalFileName = outputFilename;

encoder.PrepareToEncode(true);
encoder.Start();
}
else
{
throw new ApplicationException("File not found.");
}
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-20-2007, 08:16 AM
Balasubramanian.S Balasubramanian.S is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 182
Balasubramanian.S is on a distinguished road
Default Re: Encoding WMV file in C# .Net

Thanks Oxygen..

It is very useful to me..


Thanks...

S.Balasubramanian..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/c-programming/1728-encoding-wmv-file-c-net.html
Posted By For Type Date
Encoding WMV file in C# .Net | Web Hosting This thread Refback 01-01-2008 07:58 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
File extension of the code file & object repository file in QTP vigneshgets Testing Tools 1 01-16-2008 11:43 PM
How can I extract just the extension file name from a forms file upload field? itbarota HTML, CSS and Javascript Coding Techniques 1 10-22-2007 08:32 AM
Difference between a file and Random access file Classes anbuchezhians Java Programming 1 08-08-2007 02:53 AM
Serialization and Encoding vigneshgets C# Programming 1 08-01-2007 11:37 PM
Encoding String Anandavinayagam PHP Programming 0 03-29-2007 12:49 AM


All times are GMT -7. The time now is 05:18 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0