How to change sample rate of bulk .wav files with bash script?

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
User avatar
taersh
Posts: 951
Joined: Tue Jul 07, 2020 11:13 pm
Location: Germany
Has thanked: 53 times
Been thanked: 119 times

How to change sample rate of bulk .wav files with bash script?

Post by taersh »

Hi.

I want to change the sample rate of a bulk of .wav files from 48000 to 44100. How can I do this via bash script and e.g. ffmpeg?
Perhaps there's something other/easier to use than ffmpeg?

Thanks

My Music:
https://soundcloud.com/user-633698367
Using my own build of Bionic64
The far-left is as fascist as the far-right is!

User avatar
Flash
Moderator
Posts: 901
Joined: Tue Dec 03, 2019 3:13 pm
Location: Arizona, U.S.
Has thanked: 46 times
Been thanked: 105 times

Re: How to change sample rate of .wav file?

Post by Flash »

If your pup has Menu -> Multimedia -> FFConvert multimedia converter, I'd say look into it. The UI takes some getting used to but I think you'll be able to do what you want with it. There are several other Puppy programs that might work. I think they all use ffconvert. Multimedia -> mhWaveEdit is a very powerful program. You drag the file you want to change into its window, then play around with it.

Chaos coordinator :?
User avatar
taersh
Posts: 951
Joined: Tue Jul 07, 2020 11:13 pm
Location: Germany
Has thanked: 53 times
Been thanked: 119 times

Re: How to change sample rate of .wav file?

Post by taersh »

Thanks, but no. I don't have FFConvert installed.
Where to find?

My Music:
https://soundcloud.com/user-633698367
Using my own build of Bionic64
The far-left is as fascist as the far-right is!

User avatar
Grey
Posts: 2003
Joined: Wed Jul 22, 2020 12:33 am
Location: Russia
Has thanked: 75 times
Been thanked: 364 times

Re: How to change sample rate of .wav file?

Post by Grey »

Sometimes QWinFF helps me out.
Homepage http://qwinff.github.io/
Github https://github.com/qwinff/qwinff

Fossapup OS, Ryzen 5 3600 CPU, 64 GB RAM, GeForce GTX 1050 Ti 4 GB, Sound Blaster Audigy Rx with amplifier + Yamaha speakers for loud sound, USB Sound Blaster X-Fi Surround 5.1 Pro V3 + headphones for quiet sound.

User avatar
taersh
Posts: 951
Joined: Tue Jul 07, 2020 11:13 pm
Location: Germany
Has thanked: 53 times
Been thanked: 119 times

Re: How to change sample rate of .wav file?

Post by taersh »

@Grey
Thanks.
I have QWinFF installed and it does what I want.
But I still would like to know how to do this via bash script and ffmpeg (or whatever tools are there).

My Music:
https://soundcloud.com/user-633698367
Using my own build of Bionic64
The far-left is as fascist as the far-right is!

User avatar
Grey
Posts: 2003
Joined: Wed Jul 22, 2020 12:33 am
Location: Russia
Has thanked: 75 times
Been thanked: 364 times

Re: How to change sample rate of .wav file?

Post by Grey »

taersh wrote: Wed May 19, 2021 1:15 am

(or whatever tools are there).

Maybe then SoX. "Swiss Army knife of sound processing". Old but good. It is in PPM. Something like:

Code: Select all

sox input.wav output.wav rate 44k

HELP

Fossapup OS, Ryzen 5 3600 CPU, 64 GB RAM, GeForce GTX 1050 Ti 4 GB, Sound Blaster Audigy Rx with amplifier + Yamaha speakers for loud sound, USB Sound Blaster X-Fi Surround 5.1 Pro V3 + headphones for quiet sound.

User avatar
taersh
Posts: 951
Joined: Tue Jul 07, 2020 11:13 pm
Location: Germany
Has thanked: 53 times
Been thanked: 119 times

Re: How to change sample rate of .wav file?

Post by taersh »

Thanks.

I have Sox installed. Will try this.

My Music:
https://soundcloud.com/user-633698367
Using my own build of Bionic64
The far-left is as fascist as the far-right is!

kiash
Posts: 2
Joined: Fri Aug 06, 2021 5:34 pm

Re: How to change sample rate of .wav file?

Post by kiash »

You can use ffmpeg commad line tools to change sample rate of .wav file

ffmpeg.exe -i "Audio Input FilePath" -b:a 64k "Audio Output FilePath"

Hello :thumbup2: ! Im kiash. A full stack developer. my personal website Kiash.io Right now im working on Slide.pub as a lead backend developer.

User avatar
Grey
Posts: 2003
Joined: Wed Jul 22, 2020 12:33 am
Location: Russia
Has thanked: 75 times
Been thanked: 364 times

Re: How to change sample rate of .wav file?

Post by Grey »

ffmpeg.exe -i "Audio Input FilePath" -b:a 64k "Audio Output FilePath"

Hi. First, you seem to be used to Windows :) Secondly, even if you remove the .exe, it will hardly work. The starter of the topic says about sampling frequency (Hz), and you have bitrate (kbit/s).

Therefore, the command should be like this:

Code: Select all

ffmpeg -i test.wav -ar 44100 test1.wav

Fossapup OS, Ryzen 5 3600 CPU, 64 GB RAM, GeForce GTX 1050 Ti 4 GB, Sound Blaster Audigy Rx with amplifier + Yamaha speakers for loud sound, USB Sound Blaster X-Fi Surround 5.1 Pro V3 + headphones for quiet sound.

Post Reply

Return to “Programming”