Learn how to a build a cloud-first strategyRegister Now


How to programmatically create MP3 preview clips for ASP .Net?

Posted on 2007-07-26
Medium Priority
Last Modified: 2008-03-04
Can anyone recommend a MP3 encoder SDK (e.g. LAME) for .Net development based on personal experience? I need to generate a MP3 preview clip when someone uploads a full-length MP3 to a web site. I am using ASP .Net 2.0 and C# on a Windows Enterprise 2003 server. I would like some specific pros, cons, gotchas, tips, etc. from someone who has implemented this type of functionality before. Thanks!
Question by:moxie96
  • 4
  • 3

Expert Comment

ID: 19615325
I haven't done this exact thing before, but I've done something similar (converted images as they are uploaded).

What I did

1) Create a Windows Service and have it run on the server
2) Watch an uploads directory
3) When a file is uploaded, verify it is valid
4) Run your encoder/converter via command line using whatever options are required (don't know exact command line for LAME).

Alternatively, you can do this without a windows service, and have it run as part of your asp.net web app, but this might take a while so you may not want to keep the user waiting.

Author Comment

ID: 19643532
Hi betocarranza,
Thanks for your input - it's been surprisingly difficult to get responses to my MP3 question. My client does not want to implement a batch/async/offline solution. Just as you've done, I've implemented code to automatically create thumbnails for uploaded images. They want MP3 preview clips to be created in a similar way - in real time. Their perspective is that if video sites like YouTube can automatically create a Flash preview, why can't we create an audio preview automatically. The wait for conversion is acceptable to them. The issue is figuring how to programmatically generate the MP3 preview clips real-time.  :)

Accepted Solution

betocarranza earned 2000 total points
ID: 19643844
Hi moxie,

Well, you could modify the solution above so that it does something like

1) User uploads a file
2) Codebehind calls process.start() and passes in the relevant command line operations to generate the mp3 preview (or, you could put this functionality into an external library and call it from your codebehind).

The only issue I see is that say the operation takes 10 seconds, the website will effectively hang until the command line operation returns. Would your client accept something like that, but maybe with an async-style "Please Wait....Generating Preview" graphic?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 19667818
I need a more robust and secure solution than command line. There has to be .Net libraries for encoding MP3s, right? I think LAME has some I can use so I guess I'll pursue integrating that until someone can offer a better alternative... I'm still hoping someone who has done this before finds this thread and can give us some insight! :)

Expert Comment

ID: 19668049

Author Comment

ID: 19674159
Thanks betocarranza - It's not quite what I'm looking for - plus I'd like a C# code solution if possible. I think using a .Net wrapper around the Lame DLL is probably a better option for my client. I don't think they'd like/allow the web site app to be calling an external executable like that. I appreciate your help in rooting out options. I am surprised that there's no obvious .Net library to create MP3 clips. I wonder how all the existing music sites are doing this...? I'm still hoping other people will submit additional options but I will definitely reward you some points once I'm ready to close this thread!

Expert Comment

ID: 19675080
Again, this one might not be quite to your needs, but might get you going in the right direction :


I notice however the author of that basically says he couldn't find a complete solution to the mp3 ripping / encoding problem using C#. Might get you going though, good luck anyway!

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to record audio from input sources to your PC – connected devices, connected preamp to record vinyl discs, streaming media, that play through your audio card: Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10 – both 32 bit & 64.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Viewers will learn how to create and use Simpler instruments in Ableton Live. Load new Simpler into an empty MIDI track: Select a sample and drop it into sample window in Simpler: If sample is not pitched at C3, adjust tuning with Transpose para…
Viewers will learn how to use LFOs to modulate the sound of their Sampler instruments. Click the Modulation tab in Sampler: Choose one (or more) of the three available LFOs, and click the respective button to turn it on: Select a waveform, an LF…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question