I have two audio files that I need to merge on top of each other. Each mp3 is one side of a conversation, so in theory when I merge these two files together I should hear a complete conversation. Has anybody ever accomplished this in .Net?
I've seen examples of people concatenating audio files together, but I repeat, I don't want to do that. I want to merge/mix two audio tracks so the are on the same audio file.
Any help would be appreciated.
I am looking at the NAudio library. Actual code answers would be very helpful as well.
This should get you started with nAudio.
Convert the mp3's to wav32*
Mix the 2 wav (check this code)
Convert the mixed wav to mp3*
*the samples/discussion at nAudio shows how to convert between formats
I ended up using Sox to do the merge.
http://sox.sourceforge.net/
sox.exe -m fileone.mp3 filetwo.mp3 output.mp3
Sox doesn't have support for mp3s so you need to download this version which has those references compiled into the executable. Additionally you can search for the dll and the latest should pick them up.
http://www.codeproject.com/KB/aspnet/Compiling_SOX_with_Lame.aspx
Use a Process class to call this from .Net.
Related
I am newbie to c#. I have functionality of concatenating two or more video files using directshow.net. I have seen the documentation form http://msdn.microsoft.com/en-us/library/windows/desktop/dd375143(v=vs.85).aspx but i didn't understand how to start. I will be having two video files in the server in some folder. I want to combine those two video files and save as single video file. How can i do that using directshow.net. I am struct at this. Any help is appreciated.
DES can work good, but keep in mind it has been discontinued. Maybe this page describing how to append two wav files can help you get started. See the Time Line Model page on MSDN for an overview.
The following code works with some wav files, but with others I get, "InvalidOperationException was unhandled. Message=Sound API only supports playing PCM wave files."
var webClient = new WebClient();
webClient.DownloadFile(url, fileName);
var fileSound = new SoundPlayer(fileName);
fileSound.PlaySync();
Is there a way to programmatically check if a wav file is "bad" (not a PCM wave file) and then convert it as necessary?
What is odd is that the code works in the legacy Delphi app - all of the wav files play just fine. Here's the Delphi code:
filename := GetEnvironmentVariable('TEMP')+'\archieAndDingbat.wav';
URLDownloadToFile(nil, PChar(url), PChar(filename), 0, nil);
PlaySound(filename);
I looked at the properties of the two files in Explorer, and I see that there is, indeed, a difference. For the file that does play, its audio format is PCM; the one that won't play is CCITT u-Law.
So...I either need a way to convert from CCITT u-Law to PCM on the fly after downloading these files (they are download from an url and then played locally) OR perhaps a different way of playing these files than PlaySync() ...
Look at audiolab library from mitov. It works great
So, do you want to PLAY the file or CONVERT it ? What is the primary goal ? Do you play it as a prove you can convert it, or do you convert it because you don't know how to play not-converted file ?
http://www.catb.org/esr/faqs/smart-questions.html#goal
Your question's title claims "convert" but the body claims "Play"
This answer is about playing files.
You also may try to use FFDShow codecs directly without DirectX intermediate.
http://en.wikipedia.org/wiki/Libavcodec and http://libav.org/ and http://ffmpeg.org/ (they recently had a schism)
Googling for "FFDShow dotnet", "libav dotnet", "ffmpeg dotnet" shows a bunch of libraries to use it, such as
https://github.com/ermau/libav.net
Controlling ffdshow from .Net
Solid FFmpeg wrapper for C#/.NET
There is also BASS library. It is targeted as sound playback during gaming, so it probably has less range of formats and not much for re-coding. Still many music players are built on top of it. Some says it is the most simple API to use. So it worth considering. http://www.un4seen.com/
http://MediaInfo.sf.net is a library (native win32/win64 DLL) allowing to check most multimedia formats content.
I don't know if using tis C or C++ APis is easy from C# side.
The way to do it is to use newkie's code at: http://www.codeproject.com/Articles/175030/PlaySound-A-Better-Way-to-Play-Wav-Files-in-C?msg=4366037#xx4366037xx
In my case, at least, I had to change all of the lowercase x's to uppercase x's, though, to get it to work.
Good day everyone and happy holidays.
I'm trying to create a "simple" program that allows me to create a list of video files (Youtube video's to be precise) that are then run through by my program and converted any given format to pure MP3 audio. For this purpose I'm trying to use the BASS.dll and well it isn't going so well.
I was wondering if anyone has used BASS to convert from one audio format to another?
Or is there another library better suited for this?
If I understand correctly then the input files are YouTube videos which are FLV or F4V (MP4). Does BASS even support those formats?
Depending on your requirements, the easiest way might be to use Process.Start with ffmpeg to perform the extraction/conversion. Windows builds here: http://sourceforge.net/projects/mplayer-win32/files/FFmpeg/
I'm working on an application that will read in file paths and play audio files. I'm trying to keep this as simple as possible--by using existing codecs and free/open utilities. I'd like some suggestions on the best way to do this. I've had two ideas, both involving FFmpeg:
Create a simple GUI that allows the user to read pass in file(s) to be played, and then a ffplay.exe process is run in the background to play the file(s).
Go more in-depth by just using libavcodec and basing my project off the functionality available with that.
There are only a few main goals I have for this.
Be able to read in and play multiple files without breaks between them
Start playback at an arbitrary spot (based on a percent of total duration) within the track
Stop playback after an arbitrary amount of time, and move to the next track
Which of my two methods seem the most practical for this project? Is there a better--or perhaps less feature-intensive--alternative to FFmpeg that you would suggest.
This is for a Windows application written in C#.
Edit: One of the reasons that I started with FFmpeg is that it can handle many file types, notably MP3, AAC, Flac.
Edit2: If the use of libavcode.dll is the best option, it would also be helpful to get some info on implementing that in C#.
The BASS audio library has C# bindings and works very well with common audio formats (e.g. MP3) with plug-ins for other formats (e.g. AAC).
However, for commercial development, you require a license to use BASS.
I am trying to split a large AVI 2.0 (OpenDML format) file in smaller parts (under 1GB in my case) in order to be able to open the parts with VFW (avifil32.dll).
What is the best way to achieve this splitting (preferably in C#)?
One of the options is to copy it frame by frame. I found some examples on the net, which do the same. But most of these use VFW which can't read files above 2GB in general and AVI 2.0 files above 1GB because of the max RIFF part size of 1GB.
I would need DirectShow instead of VFW. I am pretty sure that I would also mess up the audio sync if I try to manually copy frames.
I am looking for something similar to what VirtualDub does with "direct stream copy" that doesn't affect the current compression, just splits the file and creates proper AVI indexes.
Avi files can be encoded in many different ways, depending on the codec used. Avi is a wrapper file, not an encoding method. This means there isn't really an easy generic way to split avi files using C#.
To do it in code from scratch would be a major undertaking. That said, you can cheat by using mencoder and calling it from c# - not ideal, but far easier and more reliable than trying to re-invent the wheel. Alternatively, there are a number of ffmpeg c# wrappers that will give you access the ffmpeg tools (but I haven't found one that isn't buggy as hell)
What are you trying to do, exactly? Why do you need avifil32.dll and how are you using it? If you are just trying to play a very large avi file, there are alternatives. Try aforge.net, for example.
mencoder can split files for you. Another option is ffmpeg