Comments (26)
It has been tested on the windows platform, and there is no conversion problem. However, there is still an interrupt problem at present. It may be my code problem. I will try another way to write it later
from node-flac-bindings.
i love you boy! I'm crazy for you~
from node-flac-bindings.
By the way, both MAC and Windows convert the same file directory structure
from node-flac-bindings.
const decoder = new FileDecoder({
file: musicPath,
})
decoder.once('data', (chunk) => {
const encoder = new wav.Writer({
channels: decoder.getChannels(),
bitDepth: decoder.getBitsPerSample(),
sampleRate: decoder.getSampleRate(),
})
encoder.write(chunk)
decoder
.pipe(encoder)
.pipe(fs.createWriteStream(musicPath.replace(".flac", ".wav")))
.on('error', (e) => {
return reject(e.message)
})
})
decoder.on('end', () => {
return resolve(path.parse(musicPath).name)
})
from node-flac-bindings.
I think I know what the problem is. Files can be accessed in the main process through Node, but not in the UI process
from node-flac-bindings.
Hi, sorry for late response.
The FileDecoder
and FileEncoder
classes uses C APIs to read and write files. Maybe in Windows, those APIs are not available (or they do not work as expected) on the UI process of Electron.
A bit surprised to see that you managed to get the UI process to load the package. Some time ago I wanted to use my library in an experiment with Electron and I had to write all code in the node process. Nevertheless, happy to see at least it is working somehow in Electron.
Back to the issue, I would suggest to use const inputStream = fs.createReadStream(musicPath)
and pipe it to a StreamDecoder
. If you can read files using node APIs on Windows, then this trick may work for you:
// note: write this from memory, maybe there is something wrong :/
const inputStream = fs.createReadStream(musicPath)
const decoder = new StreamDecoder()
inputStream.pipe(decoder)
decoder.once('data', (chunk) => {
const encoder = new wav.Writer({
channels: decoder.getChannels(),
bitDepth: decoder.getBitsPerSample(),
sampleRate: decoder.getSampleRate(),
})
encoder.write(chunk)
decoder
.pipe(encoder)
.pipe(fs.createWriteStream(musicPath.replace(".flac", ".wav")))
.on('error', (e) => {
return reject(e.message)
})
})
decoder.on('end', () => {
return resolve(path.parse(musicPath).name)
})
Hope it helps :)
from node-flac-bindings.
3Q, i will try it recently, and report my result
from node-flac-bindings.
Hello, I tried streamdecoder on Windows and it can be converted. But so far I've found that when I recursively convert a lot of songs. Conversion callbacks do not return 100%. So if you do this recursively it will terminate. In addition FileDecoder after many tests does not exist this problem.
from node-flac-bindings.
function flacToWav(musicPath: string, isWindows: boolean) {
return new Promise(function (resolve, _) {
console.log(musicPath)
let decoder: any
if (isWindows) {
const inputStream = fs.createReadStream(musicPath)
decoder = new StreamDecoder({})
inputStream.pipe(decoder)
} else {
decoder = new FileDecoder({
file: musicPath,
})
}
decoder.once('data', (chunk: any) => {
const encoder = new wav.Writer({
channels: decoder.getChannels(),
bitDepth: decoder.getBitsPerSample(),
sampleRate: decoder.getSampleRate(),
})
encoder.write(chunk)
decoder
.pipe(encoder)
.pipe(fs.createWriteStream(musicPath.replace(".flac", ".wav")))
.on('error', (e: any) => {
console.log(e)
return Promise.resolve({musicPath: musicPath, reason: "convert fail"})
})
})
decoder.on('end', () => {
const name = path.parse(musicPath).name
console.log("convert over: " + name)
return resolve({musicPath: musicPath, reason: undefined})
})
})
}
from node-flac-bindings.
I'm not sure how it can get stuck with a lot of conversions... Are they run one by one, or all at the same time?
Also notice that in your code, when it fails in the on error, you don't call to the resolve
method. You will know it failed because of the console.log
but the code will get stuck because the Promise
of flacToWav
is not resolved (nor rejected).
from node-flac-bindings.
yes, they are one by one.
I don't see any printout for the error, which means console.log is not executing
you can see my code through github, and url is
https://github.com/zhushenwudi/LoveLiveMusicPlayer/blob/dev/src/main/util.ts
If you have any ideas, you can write some pseudo-code for reference
from node-flac-bindings.
Oh no errors then. Okey so. When it gets stuck, it does with any specific flac file? Maybe the issue is the StreamDecoder has something wrong handling that file (or a set of files).
Also, you can try to "debug" a bit the code using the DEBUG=flac:*
environment variable. But not sure if you will get anything if the code runs on the Chromium process of Electron. This flag tells another library called debug
to print messages to the console. If you manage to find the files that makes get stuck or fail, and run your code in a simple node script with the variable, we may find the issue.
Hope it helps you to find something.
Edit: I see that the conversion code runs on the main process (the node one). The DEBUG
trick may work then, on the console should appear a lot of debug text (and a lot I mean A LOT).
from node-flac-bindings.
Okay, let me try it, reply late
from node-flac-bindings.
Hello, after two days of testing, I found that there is no format conversion problem in debug mode. Hundreds of songs can be successfully converted one by one. On the other hand, there are still no callbacks when not in Debug mode
from node-flac-bindings.
end of debug message
2022-06-24T14:10:37.069Z flac:decoder:stream Read 8192 bytes from stored chunks to be decoded
2022-06-24T14:10:37.070Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.070Z flac:decoder:stream Processing data
2022-06-24T14:10:37.070Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.071Z flac:decoder:stream Processing data
2022-06-24T14:10:37.071Z flac:decoder:stream Read 8192 bytes from stored chunks to be decoded
2022-06-24T14:10:37.071Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.072Z flac:decoder:stream Processing data
2022-06-24T14:10:37.072Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.073Z flac:decoder:stream Processing data
2022-06-24T14:10:37.073Z flac:decoder:stream Read 8192 bytes from stored chunks to be decoded
2022-06-24T14:10:37.073Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.073Z flac:decoder:stream Processing data
2022-06-24T14:10:37.074Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.074Z flac:decoder:stream Processing data
2022-06-24T14:10:37.074Z flac:decoder:stream Read 8192 bytes from stored chunks to be decoded
2022-06-24T14:10:37.076Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.077Z flac:decoder:stream Processing data
2022-06-24T14:10:37.078Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.079Z flac:decoder:stream Processing data
2022-06-24T14:10:37.080Z flac:decoder:stream Read 8192 bytes from stored chunks to be decoded
2022-06-24T14:10:37.084Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.085Z flac:decoder:stream Processing data
2022-06-24T14:10:37.085Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.085Z flac:decoder:stream Processing data
2022-06-24T14:10:37.086Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.086Z flac:decoder:stream Processing data
2022-06-24T14:10:37.086Z flac:decoder:stream Read 8192 bytes from stored chunks to be decoded
2022-06-24T14:10:37.087Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.087Z flac:decoder:stream Processing data
2022-06-24T14:10:37.087Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.088Z flac:decoder:stream Processing data
2022-06-24T14:10:37.088Z flac:decoder:stream Read 8192 bytes from stored chunks to be decoded
2022-06-24T14:10:37.089Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.089Z flac:decoder:stream Processing data
2022-06-24T14:10:37.089Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.089Z flac:decoder:stream Processing data
2022-06-24T14:10:37.090Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.090Z flac:decoder:stream Processing data
2022-06-24T14:10:37.090Z flac:decoder:stream Read 8192 bytes from stored chunks to be decoded
2022-06-24T14:10:37.091Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.091Z flac:decoder:stream Received 13186 bytes to process
2022-06-24T14:10:37.091Z flac:decoder:stream Processing data
2022-06-24T14:10:37.092Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.092Z flac:decoder:stream Processing data
2022-06-24T14:10:37.092Z flac:decoder:stream Read 8192 bytes from stored chunks to be decoded
2022-06-24T14:10:37.093Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.093Z flac:decoder:stream Processing final chunks of data
2022-06-24T14:10:37.094Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.095Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.095Z flac:decoder:stream Read 8192 bytes from stored chunks to be decoded
2022-06-24T14:10:37.096Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.096Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.097Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.097Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.098Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.099Z flac:decoder:stream Read 4994 bytes from stored chunks to be decoded
2022-06-24T14:10:37.099Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.100Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.100Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.100Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.101Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.101Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.102Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.102Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.102Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.103Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.103Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.104Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.104Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.104Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.105Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.105Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.106Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.106Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.106Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.107Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.107Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.108Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.108Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.108Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.109Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.109Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.111Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.111Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.111Z flac:decoder:stream Received 4096 samples (16384 bytes) of decoded data
2022-06-24T14:10:37.112Z flac:decoder:stream Received 3156 samples (12624 bytes) of decoded data
2022-06-24T14:10:37.112Z flac:decoder:stream Flushing decoder
from node-flac-bindings.
Hello! Now I have some time to investigate more. I found that in FLAC documentation, the function I use to initialize the FLAC Decoder in FileDecoder
, on Windows, it does not support paths with non-ascii characters. An example:
The first uses a path with non ascii characters (รฑ and รง), the second one does not use any of these. I will investigate if I can workaround this limitation on Windows for the version you have (and if I succeed I'll publish a version for it).
For the other issue with StreamDecoder
and no callbacks being called, I'm trying to replicate somehow the issue with the code of your project (adapted for a smaller usage) on Windows. But for now, I always get all files converted fine and without DEBUG enabled.
For now, I will focus on the Unicode path support on Windows which should be better for your use case. I'll report back soon.
from node-flac-bindings.
that's fine, thanks.
After I let my code run by my friend, streamdecoder does have an interrupt. But it doesn't matter if filedecoder can be done well
from node-flac-bindings.
H!, good to hear that it works (in other machine tho) :)
From my side, I found that the official FLAC library fixed this issue with Windows and non-ascii characters in paths, so I'm preparing the v2.7.1
release with the updated flac library updated.
from node-flac-bindings.
that's very good!!
There is another question, please take a look at it~
from node-flac-bindings.
Published 2.7.1! Try to use FileDecoder
now on Windows and tell me if it is working now.
I'm looking the other question, and left an answer there. I will update the other one soon...
from node-flac-bindings.
Thank you. I will test it in the local environment and give feedback. Another problem will bother you~ ^_^
from node-flac-bindings.
Good news at last! Happy to see now it is working (more or less), at least the paths are no an issue on Windows :)
If you think this is solved, feel free to close the issue. But if you prefer to wait until you check the "interrupt problem", for me, it is fine ๐
Thanks for your patience and the help provided for resolving the issue.
from node-flac-bindings.
Another question, is there a 32-bit windows node file?
from node-flac-bindings.
Currently I do not provide 32 bit binaries of the compiled package, but I could try to create them. I'm not very expert on the Windows side but I surely will investigate it.
I planned to add support for Apple M1/M2 chips, so Windows 32-bit is something I can look at as well.
Will add an answer soon (hopefully today).
from node-flac-bindings.
So I managed to compile the code for windows 32-bit (not for Apple new chips, but nobody asked for them so...).
I uploaded the precompiled binaries for the 2.7.1 version :)
from node-flac-bindings.
I'm supper happy to see all your problems are fixed :D
Thanks for raising the issues, they improved the library!
If there is anything else I can help you with related to the library, don't hesitate to raise a new issue. I'm closing this issue, but feel free to reopen if I'm missing something else.
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
- "Encoder has not been initialized yet" Error raised while using StreamEncoder HOT 7
- 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
- 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.