jiaaro / pydub

Manipulate audio with a simple and easy high level interface
http://pydub.com
MIT License
8.92k stars 1.05k forks source link

OSError: [Errno 22] Invalid argument #347

Open czhanacek opened 5 years ago

czhanacek commented 5 years ago

Steps to reproduce

I'm just concatenating 12-16 mp3s and trying to export them.

showFile = None
for s in shows[show]:
        sound = AudioSegment.from_mp3("audio/" + s["location"])
        if(showFile == None):
            showFile = sound
        else:
            print("Concatenating " + s["location"])
            showFile += sound

    if(showFile != None):
        print("Exporting...")
        showFile.export("/Users/czhanacek/Documents/Coding/saveTheWave/audio/show-" + s["location"])
        showFile.close()
        print("Exported.")

Expected behavior

The concatenated audio file should be written to the location specified when showFile.export(...) is called.

Actual behavior

I get this traceback

Traceback (most recent call last):
  File "main.py", line 81, in <module>
    showFile.export("/Users/czhanacek/Documents/Coding/saveTheWave/audio/show-" + s["location"] + ".mp3")
  File "/Users/czhanacek/.local/share/virtualenvs/saveTheWave-1L0c9War/lib/python3.5/site-packages/pydub/audio_segment.py", line 801, in export
    wave_data.writeframesraw(self._data)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/wave.py", line 422, in writeframesraw
    self._file.write(data)
  File "/Users/czhanacek/.local/share/virtualenvs/saveTheWave-1L0c9War/lib/python3.5/tempfile.py", line 483, in func_wrapper
    return func(*args, **kwargs)
OSError: [Errno 22] Invalid argument

Your System configuration

This is on Mac OS 10.14.1 (Mojave)

Is there an audio file you can include to help us reproduce?

I'm concatenating all the audio files from the same date.

'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-150000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-151500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-153000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-154500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-160000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-161500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-163000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-164500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-170000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-171500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-173000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-174500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-180000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-181500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-183000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-184500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-190000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-191500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-193000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-194500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-200000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-201500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-203000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181206-204500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-150000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-151500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-153000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-154500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-160000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-161500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-163000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-164500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-170000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-171500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-173000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-174500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-180000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-181500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-183000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-184500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-190000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-191500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-193000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-194500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-200000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-201500.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-203000.mp3', 'https://rfa-rackspace-archive-prod.s3.amazonaws.com/knhc_20181129-204500.mp3'

eykd commented 4 years ago

Based on this other issue with a similar traceback in pytorch, I found this unresolved issue in python involving seeking in files with offsets larger than 2^63. Could this be the underlying problem? I think this error is also related to #135.