Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET mp3 audio Automation , +
I am working on streaming audio files in HTML5. The requirements are to supply both mp3 and ogg files to handle different browsers. If a user uploads test.mp3, I need to generate a copy called test.off, and vice versa.
 
I realize the conversion can be done manually with free tools users can download, but I want to automate this process on the web server to ensure both file types are available if the user does not upload both versions.
 

User Uploads MP3---->Server Copies MP3---->Server Converts MP3 Copy to OGG
 
This is the format I'll be using for my HTML5 audio in an ASP.NET environment, only generated from my database.
 
<audio>
  <source src="test.ogg" type="audio/ogg">
  <source src="test.mp3" type="audio/mpeg">
   Your browser does not support the audio element.
</audio>
 

 

Thanks for any advice. Please do not post links to tools that require manual client side conversion.
Posted 26-Mar-13 9:29am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Both formats, and a lot more, are supported by FFmpeg or libavcodec, which are the best libraries I know. Please see:
http://en.wikipedia.org/wiki/Ffmpeg[^],
http://ffmpeg.org/[^],
http://en.wikipedia.org/wiki/Libavcodec[^],
http://libav.org/[^].
 
You can use them on the server-side either directly, as the utilities, or as the libraries (please see below.) Use the codec "libvorbis".
 
In both cases, you can get free open-source utilities which can make nearly everything, including assembling your video from frame pictures.
 
Now, how to use it programmatically in a .NET application? First, you can use the available utility by running it using System.Diagnostics.Process.Start:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx[^].
 
If this is not good enough, you can wrap the library in a .NET assembly by yourself or find appropriate wrapper. Please see:
http://www.ffmpeg-csharp.com/[^],
http://sourceforge.net/projects/sharpffmpeg/[^],
http://vbffmpegwrapper.codeplex.com/[^].
 
After all, try to find some more: http://bit.ly/VpboUJ[^].
 
If you wish to work at such wrapper by yourself but don't know how, ask a question, I'll give you the basic ideas (using P/Invoke or C++/CLI "mixed-mode" project).
 
See also my past answers:
HTML5 and Mime, Streaming a video?[^],
how to convert image to video in C#[^].
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 26 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100