Comments (7)
Hi, thanks for raising the issue. Let's see...
When you use one of StreamEncoder
, FileEncoder
, StreamDecoder
or FileDecoder
, the encoder/decoder is initialised when the first write/read is requested from the stream (they are all node.js streams). Talking about StreamEncoder
, the encoder is initialised inside the _transform
method:
node-flac-bindings/lib/encoder.js
Line 122 in 67f5d45
It is done before doing any encoder call, and according to node.js documentation, the stream is paused until I call callback
(which is done when something fails, or after sending the data to be processed by flac). So, theorically only one _transform
method is running at the same time.
Well there is also the _flush
method, that is called by node when you (for example) call flacEncoder.end()
. This method, according to the docs, is called when there is no more data to read (so after _transform
has been called and all their callback
s called back). In the _flush
method is where the encoder is de-initialised, but because the stream is being closed, it should not be a problem.
With that facts, you got the Encoder has not been initialised yet
error for some reason I cannot imagine currently. So if you are able to provide some stack traces or logs, would be helpful.
Something I never had is some debug logs for the library, so maybe today is a good day to add them to track this kind of weird issues (I will provide more information when I have this done).
Once again, thanks, and glad to hear you like the project :)
from node-flac-bindings.
Ah ok. I think I see what's happening. My client is closing the connection before sending any PCM data, so _write is never being called. It looks like this:
- Client opens connection
StreamEncoder()
is created
stream is passed to S3 Uploader to start streaming to S3. (not sure if this is relevant) - Client immediately closes connection without sending audio data
flacEncoder.end()
raises 'Encoder has not been initialized yet' error.
Thank you for your help!
from node-flac-bindings.
Mmmm that makes a lot of sense in fact! That's a good point.
I will create a fix for this, so if for some reason, the user does not provide any data (like in your case), send an empty flac file or something like this.
from node-flac-bindings.
Yeah, I actually think you could argue this is not a bug. I can see two possible "fixes" in this case:
- Encoder's readable stream never emits any data.
- Encoder throws an error on
end
, but it says something more descriptive like, "Encoder never received any data to encode".
I think both behaviors would be reasonable.
from node-flac-bindings.
Finally implemented the "no data emitted" fix for this ce03102. Also added tests to cover this scenarios for StreamEncoder
, FileEncoder
and StreamDecoder
(did not see any way to replicate this in FileDecoder
).
Should not error anymore when calling .end()
without writing anything to the stream :)
Thanks for everything, really helped to improve the library. Closing the issue for now. If you see the same error after the release, feel free to reopen it. I will publish a new version later this weekend.
from node-flac-bindings.
Hi again, I published a new version of the package 2.5.0
with this fix. Just to let you know :)
from node-flac-bindings.
Thank you so much. I will deploy it and let you know if I encounter and more issues
from node-flac-bindings.
Related Issues (20)
- Can't instantiate flac.FileDecoder HOT 9
- prebuild-install WARN install No prebuilt binaries found (target=12.18.0 runtime=node arch=x64 libc= platform=win32) HOT 8
- Any documentation on how to write metadata to a flac file? HOT 5
- FLAC StreamDecoder unable to decode file when FileDecoder does HOT 17
- Installation fails on Android HOT 4
- Crashes on node 14.x HOT 2
- how to create metadata HOT 4
- Illegal instruction (Core dumped) error on Synology DS718+ HOT 10
- Decoder initialization failed: Error_opening_file HOT 26
- When I packaged the Electron project, it didn't work HOT 8
- Windows build errors HOT 11
- A specific song cannot be converted on windows HOT 16
- upgrade to 3.0.0, ES module error HOT 15
- New release breaks my code HOT 8
- macbook pro m1, 13.2 (22D49) can't load libflac HOT 6
- Support for foreign metadata RIFF chunks HOT 3
- 24bit encoding HOT 7
- FLAC compressionLevel parameter is ignored HOT 5
- Miss check object on ptr HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-flac-bindings.