.WAV / .wav batch conversion to mp3

Moderator: Forum moderators

Post Reply
User avatar
greengeek
Posts: 1200
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 340 times
Been thanked: 145 times

.WAV / .wav batch conversion to mp3

Post by greengeek »

NOTE : new version for multiple pups and able to handle spaces in filenames
See here : viewtopic.php?p=105096#p105096

Original version below was for Tahr32 but see above for link to new "multi pup"version:

I needed to convert a directory full of mixed .WAV and .wav files to mp3 so came up with a GTK utility to do it.

I have only programmed selection of either 128 or 192kb/s so far but will likely add more.

The resulting mp3s are placed in the same directory as the source WAV/wav files.

So far only tested on Tahr32 (probably more testing and development to come on other pups)

Please remove the false .gz suffix then place in /root or wherever you prefer. Make executable then click to run:

WAVwav2mp3_tahr32-0.1.gz
(2.12 KiB) Downloaded 23 times

** NOTE ** - This original version does not handle filenames with spaces. Please use newest version as referred at top of post.

Edit: As suggested by Bigpup here is a .pet (probably only suitable for Tahr32 at this stage due to Tahr's use of avconv - in contrast to other pups that use ffmpeg)

WAVwav2mp3_tahr32-0.1.pet
(7.52 KiB) Downloaded 23 times

** NOTE ** - This original version does not handle filenames with spaces. Please use newest version as referred at top of post.

NOTE : I have renamed the utility and replaced the original ones with the new version. This is because it turns out there was already a script called wav2mp3 in Tahr. That version did not seem able to see WAV files (only wav files) hence the rename of my version.

Last edited by greengeek on Mon Dec 04, 2023 7:18 am, edited 9 times in total.
User avatar
snoring_cat
Posts: 206
Joined: Tue Sep 21, 2021 3:40 pm
Location: Earth
Has thanked: 24 times
Been thanked: 46 times

Re: .WAV / .wav batch conversion to mp3

Post by snoring_cat »

Hi greengeek,

Your program looks straight forward. I use ffmpeg, so I think the following update to your code might make it more usable

Code: Select all

if [[ -x `which ffmpeg` ]]; then 
     ffmpeg ....
elif [[ -x `which avconv` ]]; then 
     avconv  ...
fi
Last edited by snoring_cat on Mon Oct 04, 2021 5:07 pm, edited 1 time in total.

Meeeooow!

-- substance over noise, since 5 minutes in the future --

User avatar
greengeek
Posts: 1200
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 340 times
Been thanked: 145 times

Re: .WAV / .wav batch conversion to mp3

Post by greengeek »

snoring_cat wrote: Sun Oct 03, 2021 2:40 am

I use ffmpeg, so I think the following update to your code might make it more usable

Thanks s_c, that will be very useful.

I normally use ffmpeg too and have a number of handy scripts that use ffmpeg but I found them troublesome in Tahr because it was released at a time when avconv was flavour of the month and didn't have a native ffmpeg inbuilt. I tried various static versions but static is not always satisfactory. It took me a while to understand that avconv can do much the same as ffmpeg as long as the script calls it correctly...

I am currently building an updated pup based on Tahr32 and haven't decided yet whether to stick with avconv or compile ffmpeg to suit so I will be trying various versions of this and other GTK utilities. I currently have both avconv and ffmpeg installed in my test pup - if avconv and ffmpeg seem fully interchangeable I might as well only have one installed and use your switch to make it easy to port to other pups too. Thanks!

User avatar
MochiMoppel
Posts: 1116
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 17 times
Been thanked: 359 times

Re: .WAV / .wav batch conversion to mp3

Post by MochiMoppel »

snoring_cat wrote: Sun Oct 03, 2021 2:40 am

I think the following update to your code might make it more usable

Make it "elif", not "else if" , otherwise code won't work because it would expect another "fi".

Last edited by MochiMoppel on Sun Oct 03, 2021 8:43 am, edited 1 time in total.
User avatar
bigpup
Moderator
Posts: 6272
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 733 times
Been thanked: 1293 times

Re: .WAV / .wav batch conversion to mp3

Post by bigpup »

This being so small in size.
You could package this as a pet package, to download and install, with a menu entry, to run it.
The forum will allow a pet attachment, as long as it is no bigger than 512KiB in size.

Forum Global Moderator
The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

User avatar
greengeek
Posts: 1200
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 340 times
Been thanked: 145 times

Re: .WAV / .wav batch conversion to mp3

Post by greengeek »

bigpup wrote: Sun Oct 03, 2021 5:31 am

You could package this as a pet package, to download and install, with a menu entry, to run it.

Thanks. Added pet to first post.

User avatar
greengeek
Posts: 1200
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 340 times
Been thanked: 145 times

Re: .WAV / .wav batch conversion to mp3

Post by greengeek »

I was not happy with two issues in the original version:

1) The failure of the original version to handle spaces in the filenames or in the name of the host directory.
2) The use of avconv to suit Tahr32 only

So here is a pet that seems to work for both 32bit and 64bit pups, and using the syntax from snoring_cat it should now be happy whether ffmpeg or avconv is in use.
Can now handle spaces in filenames.

WAVwav2mp3_multipups-0.2.pet
(7.73 KiB) Downloaded 13 times

The WAVwav2mp3 converter appears in the Multimedia menu:

MultimediaMenu.jpg
MultimediaMenu.jpg (49.45 KiB) Viewed 180 times
Post Reply

Return to “Multimedia”