Problem Converting WAV file with more than 2 channels to MP3 - mp3

I am developing a C# application that records streaming audio to MP3.
I’m new to this but from what I’ve seen so far, the easiest way to do this is record to WAV using NAudio and then create an MP3 version using either LameMP3FileWriter or MediaFoundationEncoder.
I’m running into problems with the conversion, however, as my PC sound system is 5.1 and the MP3 conversion crashes due to the number of channels in the recorded WAV file. It works fine when I reconfigure my sound system to stereo but this is a bit of a pain; firstly, it means I cannot use my 5.1 system when recording the music but more of an issue, for some reason that I cannot figure out, if I set my speakers to stereo, they revert to quadraphonic when the PC (Windows 10) is rebooted!
Can anyone suggest how I can do this conversion without the need to configure my 5.1 sound?
One obvious solution to do something like resampling the WAV file to 2 channels before the conversion to MP3 but that seems something of a ‘long shortcut’. I’m also unclear as to the advantage of recording to WAV in the first place – audio streams are compressed and unlikely to have more than 2 channels to start with so playing it over 5.1, no matter how good it sounds, is really a bit illusory.
It would seem more sensible to just record the stream direct to MP3 but I cannot find any straightforward way of doing that.

Mp3 specification does not handle 5.1. So it seems your mp3 encoders fail with 5.1.
Perhaps you can try an encoder that support MP3 Surround, an mp3 extension for 5.1.
Also, Perhaps you should consider using AAC encondig, a more friendly codec for 5.1.

Related

How can I stream sound from the microphone in mp3 format?

I need a software that can stream audio with mp3 format.The audio will come from the microphone at the same time.
I have a software that can stream sound with alaw and ulaw codecs.
And I have an another program that can stream recorded mp3 file. Not capture from the microphone.
I can make stream with VLC.Dotnet wrapper but I didn't succeed with directshow.(namely microphone)
Here my Vlc.Dotnet code;
myVlcControl.Play("dshow://");
myVlcControl.Play(new Uri("dshow://"));
It did not work with this codes. I don't know what causes the problem.
My second software can stream sound that captures form microphone in real time. But its codec format is alaw not mp3. I did not find any converter that convert linear to mp3 file. I find a converter that convert linear to alaw. this is the link Linear to Alaw Codec
I know the LAME and NAudio but it converts wav file to mp3. I need linear to mp3(like in the link)
I am very confused. I really do not know which way to go.
1. Find a codec linear to mp3 (It's very complicated) ?
2. Learn VLC direct Show usage on .NET ?
Thank you so much in advance.
*VLC.DotNet, axVLCPlugin21, LAME, ffmpeg....
As soon as I've successfully solved this problem with VLC.Dotnet wrapper. The problem is compiling with x64 architectural. When I was compiled with x86 architectural, The problem solved.

How to convert from any format to PCM in Windows

I am using WASAPI to get audio data in c++ and Yeh!. I learned that conversion of audio data is not support in WASAPI, since it gives to and take from the core audio end points. I am working on a project to find exact audio frequency which needs simple PCM data only. but using WASAPI, I'm getting data with different format depends on audio devices. So, is there any simple API by windows to convert any data to PCM.
Note: I get audio using the method
IAudioCaptureClient::GetBuffer(&data,...);
or is there is any other api, that I can use It get data in PCM format directly for windows desktop and windows phone?
Audio Resampler DSP - most recent stock conversion API
Audio Compression Manager (ACM) - legacy converter offering conversions between PCM formats (also available through DirectShow wrapper over it - most likely you don't want to use it, but let's mention for the answer completeness)
Also worth mentioning FFmpeg's libswresample - popular alternative option for the conversion; you can easily find other libraries as well
See also:
How can I resample wav file
WASAPI Resampling / Windows Media Foundation
Change Audio Samplerate through this code which currently changed Bit depth?

Converting Wav in MP3

How can I convert WAV in MP3 using QtMultimedia?
There is some specific class for reading WAV and writing MP3 files?
As far as I know there is no MP3 encoder packaged with Qt. You'll have to use an external library.
Edit: this is confirmed by this thread at least as far as Qt4 is concerned (no idea about Qt5 though but I suspect it's the same).

How to encode pixels from buffer to h.264 or VP8

I have a application (qt c++) that reads data from USB-device, decodes that data into 24bit RGB pixels which are stored in a uchar array.
Framerate is ~10 FPS. Framesize is 128x4096.
Question is: How to encode these frames into VP8 or h.264 video in real time?
No external processes are allowed, everything needs to run inside my application.
ffmpeg is an option but how to include it to my project and use it? Documentation is rather bad to say the least. Also x264 could be an option but same question as to ffmpeg. And it's also quite expensive, 1$ for unit and minimum of 10000.
Simple guide would be helpful but I doubt there exists one.
Application should run in Windows and Linux.
The problem with the VP8 SDK is that the examples only encode to IVF. That codec appears to have been shut down by Microsoft due to a security flaw (buffer overflow). It's pretty hard to even get the VP8 project setup when you can't even check the results. It at least uses a BSD license scheme and its supposedly unencumbered with patents.
The VP8 SDK has some routines for converting formats, but they are buried in the source tree.
An option not mentioned is the Intel Media SDK, but that locks you to windows.
There is also Theora and Dirac.
X264 has an encoder, but it would be expensive to get a commercial license.
GPLv2 source code is not "free". I don't care what they try to get you to believe.
There is also a project called "Revel - the Really Easy Video Encoding Library". That is a path to getting MPEG-4 part 2 files encoded. H264 is MPEG-4 part 10. H264 is also called AVC. Revel is also GPL'd.
Ffmpeg is a catch all utility that tries to create a wrapper around the various encoders/decoders. If you use the x264 encoder with it, it becomes GPLv2.
The VP8 SDK has documentation and even some sample code

How to convert a FLV file recorded with Red5 / FMS to MP3?

I'm looking for a way to extract the audio part of a FLV file.
I'm recording from the user's microphone and the audio is encoded using the Nellymoser Asao Codec. This is the default codec and there's no way to change this.
ffMpeg is the way to go !
It worked for me with SVN Rev 14277.
The command I used is : ffmpeg -i source.flv -nv -f mp3 destination.mp3
GOTCHA :
If you get this error message : Unsupported audio codec (n),
check the FLV Spec in the Audio Tags section.
ffMpeg can decode n=6 (Nellymoser).
But for n=4 (Nellymoser 8-kHz mono) and n=5 (Nellymoser 16-kHz mono) it doesn't work.
To fix this use the default microphone rate when recording your streams, overwise ffMpeg is unable to decode them.
Hope this helps !
This isn't an exact answer, but some relevant notes I've made from investigating FLV files for a business requirement.
Most FLV audio is encoded in the MP3 format, meaning you can extract it directly from the FLV container. If the FLV was created from someone recording from their microphone, the audio is encoded with the Nellymoser Asao codec, which is proprietary (IIRC).
I'd check out libavcodec, which handles FLV/MP3/Nellymoser natively, and should let you get to the audio.
I'm currently using FFmpeg version SVN-r12665 for this, with no problems (the console version, without any wrapper library). There are some caveats to using console applications from non-console .NET environments, but it's all fairly straightforward. Using the libavcodec DLL directly is much more cumbersome.
I was going to recommend this: http://code.google.com/hosting/takenDown?project=nelly2pcm&notice=7281.
But its been taken down. Glad I got a copy first :-)