LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 09-25-2012, 03:03 PM   #1
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
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.
 
Old 09-25-2012, 03:35 PM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
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
 
Old 09-25-2012, 04:51 PM   #3
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467

Original Poster
Blog Entries: 60

Rep: Reputation: 51
Quote:
Originally Posted by Thor_2.0 View Post
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.)
 
Old 09-26-2012, 02:53 AM   #4
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
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
 
Old 09-26-2012, 03:31 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
probably you can try this: http://www.thegeekstuff.com/2009/05/...e-audio-files/
also try to convert stereo to mono (if applicable)
 
Old 09-26-2012, 04:06 AM   #6
cascade9
Senior Member
 
Registered: Mar 2011
Location: Brisneyland
Distribution: Debian, aptosid
Posts: 3,753

Rep: Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935Reputation: 935
Quote:
Originally Posted by hydraMax View Post
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).
 
Old 09-26-2012, 09:18 PM   #7
tux9656
LQ Newbie
 
Registered: Sep 2012
Distribution: Debian
Posts: 11

Rep: Reputation: Disabled
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.
 
Old 09-27-2012, 03:37 PM   #8
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467

Original Poster
Blog Entries: 60

Rep: Reputation: 51
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.
 
Old 09-28-2012, 12:32 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Quote:
Originally Posted by hydraMax View Post
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?
 
Old 09-28-2012, 12:57 AM   #10
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495

Rep: Reputation: 85
You can reduce the size of a wav file losslessly (without decreasing the audio quality at all) by encoding it with flac.
 
Old 04-10-2014, 04:12 AM   #11
scottnrogers
LQ Newbie
 
Registered: Apr 2014
Posts: 2

Rep: Reputation: Disabled
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
 
Old 09-28-2014, 05:08 AM   #12
mankeedly
LQ Newbie
 
Registered: Sep 2014
Posts: 1

Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
TIP: Reducing PDF file size from the command line with GhostScript (gs) ShellyCat Linux - Newbie 3 07-12-2012 04:11 AM
Photo's reducing size of for posting TinaSussex Linux - Software 3 11-17-2010 08:32 AM
Reducing size in LVM SBN Linux - General 8 07-28-2009 06:30 AM
Reducing file size using mencoder SithX Linux - Software 3 04-15-2005 08:56 PM
Reducing kernel size Kholnuu Slackware 6 01-22-2005 02:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration