AudioSegment.from_file fails if I specify 'wav'

262 views Asked by At

This is a potential 'gotcha' which I'll document here in case anyone else trips over it. I'm running a conversion on files that may be in .wav or .mov format. The test looks like this:

            if pic[0].audiodesc.path.lower().endswith('.wav'):
                sound = AudioSegment.from_file(pic[0].audiodesc.path)
                sound.export(mp3_filepath, format = 'mp3', bitrate = '64k')
            elif pic[0].audiodesc.path.lower().endswith('.mov'):
                sound = AudioSegment.from_file(pic[0].audiodesc.path, 'mov')
                sound.export(mp3_filepath, format = 'mp3', bitrate = '64k')

In AudioSegment.from_file(pic[0].audiodesc.path), if I specify .., 'wav') then the encoding fails with:

avconv version 9.20-6:9.20-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers built on Dec  7 2016 21:22:31 with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 
/tmp/tmpGhtAOn: Operation not permitted
1

There are 1 answers

0
Peter Glock On

Removing the 'wav' fixes the problem.