I recorded and mixed down a CD worth of homemade music with Ardour and stupidly exported all the songs in 48 kHz and 24 bit. Now I need it in 44,1 and 16 bit in order to have CDBaby take it and give it over to iTunes, Spotify and whatnot. I expected they'd want mp3 for that but no. I guess I'll be doing something like:
ffmpeg -i song.wav and set the new sampling rate with:
-ar 44100 But how do I get the bitrate down to 16? I haven't been able to find any hints ... most of ffmpeg questions are about video and I get lost following first one possible thread and then another one.
3 Answers
Use the default
Default for WAV output is a 16-bit encoder (pcm_s16le), so all you need to do is:
ffmpeg -i input.wav -ar 44100 output.wav Or manually declare a 16-bit encoder
ffmpeg -i input.wav -c:a pcm_s16le -ar 44100 output.wav - See a list of encoders with
ffmpeg -encoders - See what audio sample formats (bit depth) an encoder supports with
ffmpeg -h encoder=pcm_s16le
Or manually set the audio sample format
With the -sample_fmt option.
ffmpeg -i input.wav -sample_fmt s16 -ar 44100 output.wav - See a list of audio sample formats (bit depth) with
ffmpeg -sample_fmts
Or use the aformat filter
ffmpeg -i input.wav -af "aformat=sample_fmts=s16:sample_rates=44100" output.wav 4Can this be related to Sample formats?
To see options: ffmpeg -sample_fmts
For you it will be something like,
ffmpeg -i input -sample_fmt s16 -ar 44000 output
I suspect that SoX might be a better tool for this job. I created a sample file with the sampling rate of 48.0 kHz and Bit depth of 24 bits, I have arrowed in the relevant sections:
andrew@ilium~/tmp$ mediainfo luckynight_48_24.wav General Complete name : luckynight_48_24.wav Format : Wave File size : 16.6 MiB Duration : 1 min 0 s Overall bit rate mode : Constant Overall bit rate : 2 304 kb/s Audio Format : PCM Format settings : Little / Signed Codec ID : 00000001-0000-0010-8000-00AA00389B71 Duration : 1 min 0 s Bit rate mode : Constant Bit rate : 2 304 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 48.0 kHz <----- Bit depth : 24 bits <----- Stream size : 16.6 MiB (100%) Now I am no SoX master but the following command certainly converted the above file to a sampling rate of 44.1 kHz and Bit depth of 16 bits (as you have requested):
sox luckynight_48_24.wav -r 44100 -b 16 luckynight_44_16.wav This accomplished the following, and again I have arrowed in the relevant sections:
andrew@ilium~/tmp$ mediainfo luckynight_44_16.wav General Complete name : luckynight_44_16.wav Format : Wave File size : 10.2 MiB Duration : 1 min 0 s Overall bit rate mode : Constant Overall bit rate : 1 411 kb/s Audio Format : PCM Format settings : Little / Signed Codec ID : 1 Duration : 1 min 0 s Bit rate mode : Constant Bit rate : 1 411.2 kb/s Channel(s) : 2 channels Sampling rate : 44.1 kHz <----- Bit depth : 16 bits <----- Stream size : 10.2 MiB (100%) And this is exactly what you are after :)
1