Open nathanielatom opened 5 years ago
I could work on a pull request to
close=True
parameter to AudioSegment.from_file
which controls whether it closes the file passed in.
ORinfo
local variable into an AudioSegment
attribute, .info
, .media
, ._info
, or ._media
, etc.if either of these would be acceptable changes. Thoughts?
Really annoying behaviour. Any chances close
param will be added?
Steps to reproduce
Expected behaviour
Same behaviour as:
where both
audio
andmedia
get populated.Actual behaviour
ValueError: seek of closed file
is raised.Your System configuration
Is there an audio file you can include to help us reproduce?
From my testing this happens with any file.
Discussion
I have a requirement to use a file-like object, which can be very expensive to download (using a custom context manager), so I can't use more than one context manager. Similarly I need to avoid making any unnecessary copies of the buffer.
This may make sense to discuss in another issue, but I noticed
mediainfo_json
gets called insideAudioSegment.from_file
, but is only stored in a local variableinfo
. If this were an AudioSegment attribute then it wouldn't even be necessary to callAudioSegment.from_file
andmediainfo_json
together. Since custom tags can be exported directly withAudioSegment.export
, IMHO it would be more natural if they could also be accessed directly from the AudioSegment.