I'm currently working on lose size of mp3 files to streaming it.
I want to reduce size of mp3 how much how it is possible. I know best (probably) encode is HE-AAC (AAC+). He gave me 32kb/s for stereo sound of mp3 like 320kb/s from original.
I'm on Ubuntu.
I found one solution.
It's a NeroAacEnc it's free and working not bad too.
But have a bug. Input file must be a "wav" file, so when I convert first my mp3 (400mb) to wav a get more than 4GB file.
Then I can not open so large files in NeroAacEnc.
Command with -ignorelength not work
$ neroAacEnc -ignorelength -br 32000 -if test.wav -of test_nero.mp3
Can you help me, and find solution how to do it right?
Other encoders are so bad to reduce size down to 32kb/s because so lose quality. Only HE-AAC (AAC+) give me good quality and 32kb/s of my file.
EDIT:
OK I found that I can compile ffmpeg with AAC+ encoder.
http://ffmpeg.org/doxygen/trunk/libaacplus_8c-source.html
here is a source. But I don't know how to do it, anyone know?
He gave me 32kb/s for stereo sound of mp3 like 320kb/s from original.
That's a total lie. Whomever told you that has absolutely no idea what they're talking about.
so when I convert first my mp3 (400mb) to wav a get more than 4GB file
Yes, that's likely. Don't convert it to a file, pipe to it. neuroAacEnc supports -if - to read from STDIN.
Other encoders are so bad to reduce size down to 32kb/s because so lose quality.
All codecs sound bad at 32k.
Only HE-AAC (AAC+) give me good quality and 32kb/s of my file.
HE-AAC is one of your best choices, but it still isn't going to be amazing. Also consider Opus.
You might consider a pre-built FFmpeg for your usage. Really though, you shouldn't be converting from MP3 to AAC anyway. Go get the original audio if at all possible, or you're going to be wasting a lot of bandwidth trying to encode artifacts from previous lossy codecs.
OK guys, after research I finaly done what I gonna do.
However We cannot split and marge files. When you try merge files encoded in AAC+ you lose it because tools to merge files encode again files in bad codec.
But we can compress big (>4gb) wav file to aac in live by command
rm audio.fifo; mkfifo audio.fifo; cat test.wav > audio.fifo & neroAacEnc -ignorelength -br 23000 -if audio.fifo -of test.m4a
This use temporary fifo file.
Obus (ogg) are not bad too but here https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio#Recommendedminimumbitratestouse
they show us that best quality is with he-aac with lowest bitrate.
PS. I know convert from mp3, to wav to aac is not really good method but my sources files are mp3's.
PS2. I know that 32kb/s in AAC+ is not sound like mp3 320kb/s but casual user who listening music from preview in streaming he will not listen to the details and will be happy.
In case you don't find a better solution consider that .waw and .aac files are easy to split and merge.
Related
I cannot find out how I can convert a wav to mp3 and mp3 to wav. Does anyone know how to convert a .wav file into a .mp3 or .ogg and later convert back into .wav while matching 100% same size like untouched (if it can be done in the command line its much better). I tried to use LAME and later back to .wav with some tools but the file wouldn’t match 100% byte per byte like if it was never was touched. Does anyone know any command line in SoX or FFMPEG that can help me? Thanks!
Most WAV files are raw PCM. MP3 is MP3. And, most Ogg files are going to contain Vorbis or Opus.
MP3, Vorbis, and Opus, are all lossy codecs. They work by taking advantage of what we hear and what we don't hear, psychoacoustics and all that, and saving bandwidth. It's tradeoff between bandwidth and audio quality.
You cannot use the output of a lossy codec to get back to the original source. Therefore, you definitely can't expect to binary compare the outputs and get them to be the same.
You also can't even get the same file size really without knowing more about the source. For instance, the input of your MP3 codec might have been 24-bit audio, but the output of the receiving codec is almost always going to be configured for 16-bit. Also, it's common for these lossy codecs to not be sample-accurate. MP3 in particular has a problem with this. Read up on "gapless playback" if you're in doubt.
I'm not talking about any concrete language here. I want to analyse the MP3 file, so I want to get some information about sound from specific second (i don't know, tone/height/frequency of sound). How those data is stored in single file?
Unless you have weeks (months?) available to play with it, I would recommend using an existing MP3 decoding library to pull the decoded audio out of the file. In C/C++, there's libMAD or libmpg123, as well as the Windows components. In C#, you can use NAudio or NLayer.
Once you have the decoded data, you'll need to run a FFT, DFT, or DCT over it to convert to frequency & amplitude. The FFT is probably your best bet, though the DFT may give a less "noisy" analysis. YMMV.
Note that all three of the transforms provide amplitude values you can convert to decibel values.
there are some useful MP3 Librarys where you get information about your MP3 file.
If you use C# it could be NAudio.
http://naudio.codeplex.com/
I recommend the program xxd and google for the first steps.
First of all i would look into its binary code.
xxd -b file.mp3
Viewing it as ASCII also exposes some information.
xxd file.mp3
That was my first steps.
How to write mp3 frames (not full mp3 files with ID3 etc) from PCM data?
I have something like PCM data (for ex 100mb) I want to create an array of mp3 frames from that data. How to perform such operation? (for ex with lame or any other opensource encoder)
What do I need:
Open Source Libs for encoding.
Tutorials and blog articles on How to do it, about etc.
You should be able to use LAME. It has a -t command line switch that turns off the INFO header in the output (otherwise present in frame 0). If that still leaves too much bookkeeping data, you should be able to write a separate tool to strip that away.
You are already on the right track: use LAME external executable, or any other shell-invoked encoder.
To build MP frames, were your layer of interest is 3, is not easy to do from scratch. There are compression steps, Fast-fourier transforms followed by quantization, which are of complex and tediously long explanation. The amount of work required for a developer to build it from scratch is very big.
There are programmatic C and C++ MP encoding libs, but you will be either asked for fees, be left with very limited support, or have very limited interfacing options.
Go LAME, study their wiki.
Duplicate: audio and video file compressor
I would like to compress a wmv 2mb or larger file to 3gp 250kb file for mobile devices.
any great compressors for video or audio?
I'm a huge fan of ffmpeg. Find out what codec and resolution your mobile device wants. If you're lucky, H.264 will be supported.
You might have some trouble here. WMV is a container, not a codec, so we can't tell specifically the level of compression we're dealing with and what needs to be changed where, but it may be difficult to get such a dramatic reduction in filesize without making huge compromises, like decreasing the resolution of the video by several orders of magnitude. These compromises may be acceptable for mobile viewing, but there's no guarantee you'll be able to get that filesize down, especially if your file is encoded in a modern codec like H.264 or VC-1.
My first piece of advice is to attempt to locate a good wizard-like transcoder, with a nice non-developer interface on it, etc. Video compression is intense work, and the power tools behind it, and the tools that these wizard-like applications use to actually perform their work, are very complex and take lots of practice and tweaking to get right, and are usually restricted to commandlines. If your mobile device's vendor provides these utilities, for instance, you'll be much better off using them.
If you aren't able to locate such a utility, godspeed and spend lots of time with mencoder and ffmpeg's man pages and IRC rooms. It's not difficult per se, it just takes a lot of study and reading to get acceptable output, especially when you're going after the reductions you've mentioned. Good luck.
How do you programmatically compress a WAV file to another format (PCM, 11,025 KHz sampling rate, etc.)?
I'd look into audacity... I'm pretty sure they don't have a command line utility that can do it, but they may have a library...
Update:
It looks like they use libsndfile, which is released under the LGPL. I for one, would probably just try using that.
Use sox (Sound eXchange : universal sound sample translator) in Linux:
SoX is a command line program that can convert most popular audio files to most other popular audio file formats. It can optionally
change the audio sample data type and apply one or more sound effects to the file during this translation.
If you mean how do you compress the PCM data to a different audio format then there are a variety of libraries you can use to do this, depending on the platform(s) that you want to support. If you just want to change the sample rate of the PCM data then you need a sample rate conversion algorithm instead, which is a completely different problem. Can you be more specific in your requirements?
You're asking about resampling, and more specifically downsampling, not compression. While both processes are lossy (meaning that you will suffer loss of information), downsampling works on raw samples instead of in the frequency domain.
If you are interested in doing compression, then you should look into lame or OGG vorbis libraries; you are no doubt familiar with MP3 and OGG technology, though I have a feeling from your question that you are interested in getting back a PCM file with a lower sampling rate.
In that case, you need a resampling library, of which there are a few possibilites. The most widely known is libsamplerate, which I honestly would not recommend due to quality issues not only within the generated audio files, but also of the stability of the code used in the library itself. The other non-commercial possibility is sox, as a few others have mentioned. Depending on the nature of your program, you can either exec sox as a separate process, or you can call it from your own code by using it as a library. I personally have not tried this approach, but I'm working on a product now where we use sox (for upsampling, actually), and we're quite happy with the results.
The other option is to write your own sample rate conversion library, which can be a significant undertaking, but, if you only are interested in converting with an integer factor (ie, from 44.1kHz to 22kHz, or from 44.1kHz to 11kHz), then it is actually very easy, since you only need to strip out every Nth sample.
In Windows, you can make use of the Audio Compression Manager to convert between files (the acm... functions). You will also need a working knowledge of the WAVEFORMAT structure, and WAV file formats. Unfortunately, to write all this yourself will take some time, which is why it may be a good idea to investigate some of the open source options suggested by others.
I have written a my own open source .NET audio library called NAudio that can convert WAV files from one format to another, making use of the ACM codecs that are installed on your machine. I know you have tagged this question with C++, but if .NET is acceptable then this may save you some time. Have a look at the NAudioDemo project for an example of converting files.