0

I am looping through a large wave file, via a dictionary of new file names, lengths and versions. The loop exports the individual slices as files:

mix.export(key, format='wav')

However, it converts the original 24-bit file to 32-bit slices. I have been doing a round trip to pro tools to get the files back to 24, as I can't figure out either ffmpeg settings, or getting the slice into a subprocess.

I have tried several variations of this theme:

mix.export(key, format='wav', codec='pcm_s24le')

As well as this one:

mix.export(k, format='wav', parameters=['ffmpeg', '-i', '-acodec', 'pcm_s24le', '-ar', '48000'])

I can't seem to get the individual slices to work in the following subprocess call. key is the file name from the key-value pair. This works well in the 32-bit export, but not sure how to make it work when a slice's temp file, such as /var/folders/vc/q7jggn7900l099w45463lgx40000gn/T/tmpw_6mxyg8 needs to be called.

subprocess.call(['ffmpeg', '-i', key, 
                 '-acodec', 'pcm_s24le', '-ar', '48000', 'output.wav'])

Hoping for slices of the exact same format as the original input:

mix_file = AudioSegment.from_wav(file_name)
SuperKogito
  • 2,998
  • 3
  • 16
  • 37
tzujan
  • 186
  • 1
  • 10
  • *a slice's temp file* --> what is this and how is it generated? – Gyan Apr 23 '19 at 05:25
  • Hi @Gyan - Using the slice audio feature in pydub. For example: slice ten seconds after a five second gap `next_10_seconds = song[15000:25000]` – tzujan Apr 23 '19 at 14:12
  • This quirk is due to python’s stdlib `audioop` module not supporting 24 bit audio (until recently) - pydub converts 24-bit input files to 32 bit in order to take advantage of the stdlib audio functions – Jiaaro Apr 28 '19 at 03:03
  • Thanks, I'll look into audioop. I have added a subprocess where I convert the folder of files, to a new set of 24bit files. Technically, it is slower, but works great for my project. – tzujan Apr 28 '19 at 21:34

0 Answers0