Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
09-25-2012, 03:03 PM
|
#1
|
Member
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Rep:
|
reducing size of WAV file
Hi guys. I've got a problem: I need to feed audio files into an audio framework that only receives WAV files. I figured out that I could convert ogg to wav with the command "ffmpeg -i filename.ogg filename.wav. However, the resulting WAV files are huge... like 20MB for 2 minutes of audio. Rather than messing around with compressing/decompressing the files before hand, I was wondering if there was some way to cut the size of the WAV files by reducing the quality, perhaps during the transcoding process with ffmpeg. I ask this because I have seen WAV files used by old DOS programs that provide 2 minutes worth of audio, but only are about 2MB in size.
I see in the ffmpeg manual page that there is this option:
Code:
-aq q (output)
Set the audio quality (codec-specific, VBR). This is an alias for -q:a.
But I'm not sure how to get the "codec-specific" information I need, or what I should set for this option.
|
|
|
09-25-2012, 03:35 PM
|
#2
|
Senior Member
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
|
hey there hydraMax!
Just did an experiment. I used mhWaveEdit and changed the samplerate. The smple I had used 16 bit, and clocked in at 259 Mb, after ajusting to 8 bit, it clocked in at 8Mb
Maybe a helpful option...
One that seems to be available in ffmpeg....
have fun!
Thor
|
|
|
09-25-2012, 04:51 PM
|
#3
|
Member
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Original Poster
Rep:
|
Quote:
Originally Posted by Thor_2.0
hey there hydraMax!
Just did an experiment. I used mhWaveEdit and changed the samplerate. The smple I had used 16 bit, and clocked in at 259 Mb, after ajusting to 8 bit, it clocked in at 8Mb
Maybe a helpful option...
One that seems to be available in ffmpeg....
have fun!
Thor
|
Thanks for mentioning mhWaveEdit: I had never heard of that before. I installed it and it allows one to change either the sample format or the sample rate. When I change the sample format from 16 bit PCM to 8 bit PCM, for some reason this creates bad static in the audio. However, I can change the Hz sample rate, using the simulated analog filtration, and the audio is preserved. I downgraded from 44100 to 11025 and it cut the size of my file down to 1/4 the original.
I was able to do the same thing with ffmpeg using: "ffmpeg -i filename.ogg -ar 11025 filename.wav". However, I wasn't able to change the sample format: ffmpeg complains that an 8 bit sample format is not compatible with the codec used to make the WAV file.
(As a point of curiosity: were there any other things you changed when you did the conversion of the file you mentioned above? I am curious how it is that you switched from a 16 bit to an 8 bit sample type and managed to get a 32-fold decrease in the size of your file.)
|
|
|
09-26-2012, 02:53 AM
|
#4
|
Senior Member
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
|
Quote:
(As a point of curiosity: were there any other things you changed when you did the conversion of the file you mentioned above? I am curious how it is that you switched from a 16 bit to an 8 bit sample type and managed to get a 32-fold decrease in the size of your file.)
|
hey there hydraMax,
I assume it ties in with the source file (the original WAV file) itself. I jest took a file I ripped of one of my CD's (yes, I stil got some of that stuff lying around) - so it might just be as simple as that. Changien the sample rate was the only thing I did. You could, however, convert this file to, say MP3, and then back againg to have the codec "converted out" and restart from the resulting file...
Watching this thread closely now...
Thor
|
|
|
09-26-2012, 04:06 AM
|
#6
|
Senior Member
Registered: Mar 2011
Location: Brisneyland
Distribution: Debian, aptosid
Posts: 3,753
|
Quote:
Originally Posted by hydraMax
I ask this because I have seen WAV files used by old DOS programs that provide 2 minutes worth of audio, but only are about 2MB in size.
|
Even though most people think of WAVas uncompressed (normally linear pulse code modulation, LPCM) WAV files can actually contain compressed audio.
Its possible that any old 2MB/2 minute WAV files were reduced in size with playing with bit depth and sample rates, its also possible that the files were compressed with some audio codec (eg MP3).
|
|
|
09-26-2012, 09:18 PM
|
#7
|
LQ Newbie
Registered: Sep 2012
Distribution: Debian
Posts: 11
Rep:
|
I don't know what is your audio framework, but if it is non-interactive, command line based, you should be able to redirect standard output as input to your framework. For example, you could convert your audio files to wave files with no reduction of quality and then compress them with gzip. Then you could take the .wav.gz file and run it though zcat and pipe the output as input to the framework. It would work something like this:
First, convert the files to wave files.
Next, compress the wave files with gzip. (gzip --best *.wav)
Lastly, decompress the gzipped wave files and redirect the output as input to your audio framework. (zcat file.wav.gz | framework)
The | means that the output of the command to the left of the | is sent as input to the command to the right of the |.
You could also try other compressors, such as bzip2, lzop, and xz. xz and bzip2 may be too slow for realtime decoding on slower machines, though. You could also check the man page for flac. It may support decoding flac files to standard output. I think ffmpeg might even be able output to standard output.
In the case of ffmpeg, you could try something like this:
ffmpeg -i infile -f wav - | framework
The hyphen that stands alone after infile means to use standard output in place of the output file. If this works for ffmpeg, you wouldn't even need to convert your files to wave files at all.
|
|
|
09-27-2012, 03:37 PM
|
#8
|
Member
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Original Poster
Rep:
|
I tried this out on one of my wave files. Gzip only gave a 5% space savings, and bzip2 12%. This is interesting since there is about a 50% space savings using the ogg format (and that was before I cut down the sample rate). This would suggest then that ogg uses some more advance compression technique.
I suppose I could research more into that... but then it might be easier just to use a lib to do live conversion of ogg -> wave.
|
|
|
09-28-2012, 12:32 AM
|
#9
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,702
|
Quote:
Originally Posted by hydraMax
I tried this out on one of my wave files. Gzip only gave a 5% space savings, and bzip2 12%.
I suppose I could research more into that... but then it might be easier just to use a lib to do live conversion of ogg -> wave.
|
yes, zip, bzip, gzip and similar tools cannot compress wave files (and images), there are special tools to do that.
Have you tried sox already?
|
|
|
09-28-2012, 12:57 AM
|
#10
|
Senior Member
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495
Rep:
|
You can reduce the size of a wav file losslessly (without decreasing the audio quality at all) by encoding it with flac.
|
|
|
04-10-2014, 04:12 AM
|
#11
|
LQ Newbie
Registered: Apr 2014
Posts: 2
Rep:
|
i know a wav compressor call idealshare videogo which can easily reduce wav file size, or compress other audio file size of flac, aiff, mp3, au, ape, apple lossless and etc
|
|
|
09-28-2014, 05:08 AM
|
#12
|
LQ Newbie
Registered: Sep 2014
Posts: 1
Rep:
|
I really don’t know how it is done, but Faasoft Audio Converter has that feature of compress WAV, FLAC, MP3, AIFF, AC3, AAC, DTS, M4A, WMA, etc, and I didn’t have any problem using that function.
|
|
|
All times are GMT -5. The time now is 09:03 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|