Simplify ffdec.py by using Popen.communicate() method
- Dominant language
- Python
- Stars
- 538
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
Hi, thanks for this very useful library!
I was looking into `ffdec.py` since I need faster loading of mp3 and m4a files.
I believe that the module could be improved and simplified by using the [`Popen.communicate()`](https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communicate) method. This seems to be the recommended way of retrieving output from a subprocess.
The current implementation only allows to read the data in blocks which is suboptimal since a user might not be able to adapt the block size. (E.g. librosa just calls `audio_open()` which has no way of setting a block size.)
I did a speed comparison that shows that this way of reading data is slower than it needs to be, especially for large files:
https://gist.github.com/Bomme/d9aee452c8c1e68fb5fac743df6b2a07
If you decide to drop Python 2 support (https://github.com/beetbox/audioread/issues/112) the timeout handling might be easier.
And for later versions of Python 3 the https://docs.python.org/3/library/subprocess.html#windows-popen-helpers might come in handy.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading ffdec.py, especially the subprocess output-reading loop used by audio_open(), and compare it with Python's Popen.communicate() documentation. Check how the current implementation handles block sizes, timeouts, and Python 2 support. Done means the subprocess output is handled through communicate() without breaking supported versions or audio loading behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- audio-video-rtc
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100