I try to generate the waveform image of a MP3 file the quickest way.
All solutions I found decode the Mp3 file entirely and after generates the waveform. I think this is a waste of time, because only frequencies decoding is needed.
To summarize , I would like an algorithm working like "Mp3 direct cut" software, and not like audacity... (I think soundcoud work this way)
OK, this is not the same waveform wich is generated in the 2 cases, but the fastest solution is the best for me.
Thank you for your help.
Related
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.
I want to make a screen capture utility, so far i am able to capture the screen in regular interval to get a numbered sequence of images and now i want to encode them to a video format preferably flv(because of good compression and web support)
....I tried the ffmpeg.exe for that reason but for some strange reason it did'nt work
on my vista ultimate...only the first picture is encoded while the rest -I dont know what happened to them.
Also I would prefer doing the encoding stuf programatically (using c/c++ library api if any for that purpose) rather than using tools as ffmpeg.exe and i am interested in encoding picture sequence to video not capturing contineouse video directly.
I searched through internet....there are lots of libraries and tutorial for converting between video formats but I did'nt find something usefull for my problem.
I am not verry proficient with video formats and sdk library, I just need a quick way to encode some pictures to video with some basic control (as time interval between two consecutive frames).
So can you help me with some pointers as to which library i should use and how(code fragment and little descriptive answer would greatly help) and please dont recomend any .NET solution I need to learn something out of this and dont want to apply some bruteforce approach to solve the problem.
Sorry for my english....and thanks in advance.
It appears that an .avi file can more or less directly be made of .jpg's:
An AVI file may carry audio/visual data inside the chunks in virtually any compression scheme, including Full Frame (Uncompressed), ..., Motion JPEG.
Also, something very similar has been discussed here before.
So all I need is a simple function that sets it up (eating incoming PCM RATE (for example: rate near to 44100) It's channels (for example: 2) and -bits (for example: 16) and desirable 128 kb\s rate) and another one that takes PCM data and encodes it into pure MP3 frames.
I know it looks like a silly homework task but I assure you - it is not.
I hope it will be of help to all C++ developers starting with MP3s.
So can anybody please help me with that?
See the example I gave in your other question for the basic usage of Lame. It should contain everything you need.
It's a long time since i messed with this, but Lame lib contains all you need to do it, check out lame.h , there is some test code you could look into.
Personally, I'd be looking at ffmpeg's libavcodec. There's an example file containing an audio_encode_example which ought to be more or less what you're looking for.
See also this question.
Note that not all ffmpeg packagings include mp3 codec support (patent issues) by default, although there's usually some simple way of enabling it.
GStreamer should definitely be able to handle this.
If you are on Windows you can use the GStreamer Winbuilds to get started.
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.
This question has been in my mind for a few years and I never actually found the answer for this.
What I would like to do is extract the actual waveform/PCM of an MP3 file, so that I can play it using the soundcard (of course).
Ideally I would be experimenting some DSP effects.
My first step was to look into LAME, but I didn't find anything relevant about MP3 decoding in a program or stuff like that.
So I'm asking where I could find something like this.
What language should I use? I was thinking C, but maybe there are programming languages out there that would do the job more efficiently.
Thanks!
Guillaume.
The question boils down to: what are you trying to accomplish?
From the description of your question of decoding an MP3 and playing it on the sound card makes it sounds as if you are trying to make a media player.
However, if your intent is to play around with DSP effects, then it sounds like the question is more about processing the sound rather than decoding MP3s. if that's the case, probably looking into writing plug-ins for existing media players (such as Windows Media Player and Winamp) would be easiest path to what you're trying to accomplish.
Frankly, learning to write your own decoder from scratch is not just a programming problem but a mathematical one, so using existing libraries are the way to go. Talking to the operating system or libraries like DirectSound to output audio seems like unnecessary work if anything. I feel that working on plug-ins for existing players would be the way to go, unless your goal is to make your own media player.
If what you really want to accomplish is playing with audio data, then probably decoding an MP3 to uncompressed PCM using any MP3 decoder, then manipulating it in the language of your choice would accomplish your goal of dealing with effects with sound.
The language choice is going to depend on whether you are going to interact directly with MP3 decoding libraries, or whether you can just use raw audio input, which would allow you to use pretty much any language of your choice.
There was a similar question a while back, Getting started with programmatic audio, where I posted an answer on some basic ways to manipulate audio, such as amplification, changing playback speed, and doing some work with FFT.
libmpg123 should do the trick.
I have been using the Windows Media SDK, not for this purpose, but I am pretty sure there are hooks let that let you intercept the audio stream, or convert MP4 to uncompressed WAV. I used C++.
Lots:
http://www.mp3-tech.org/programmer/decoding.html
Pick your poison...
Also, LAME does decode MP3s (check out --decode option), so you might find something interesting in that source.
-Adam
It really depends what platform you are programming on and what you want to do with the code. If you are on Windows you should look at the windows media format sdk or DirectShow. They should both have the ability to decode mp3 files into the raw waveform. On the Mac, I would expect Quicktime to have this same ability. Others have already suggested source for Linux/open source code.
I would recommend looking at Cubase and Wavelab as both will convert MP3 to WAV etc and allow you to play around with the waveform