Comments (3)
Hello! This is the first time I see this feature of the flac
tool, and I never read about it before. I will try my best to help you.
First, what you want is something you can accomplish using the available APIs (either through streams or using the metadata API level 1 or level 2). I know the metadata APIs are a bit complicated so that's why added the metadata array for the stream encoders (FileEncoder
and StreamEncoder
). I will focus on this API.
The metadata
property in the constructor just tells the encoder to write those flac metadata blocks into the output stream/file. In your example, you are adding several empty metadata blocks to the output file (not sure if libflac
sees this and removes them or something).
For that case, the idea is to read the RIFF
chunks beforehand, store each chunk in an array of buffers (the whole chunk) and then write them as application metadata with id riff
(see this). The only thing I don't know for sure if it just needs to be metadata block for all chunks or one metadata block for each chunk. My guess goes to the one for each.
Imagine that you have a library that reads all RIFF
chunks somehow using an async iterator, and puts the raw chunk in a property called raw
. The idea would look like this:
// read riff chunks
const pathToTheFile = '...'
const riffChunks = []
for await (const riffChunk of readRiffChunks(pathToTheFile)) {
const riffApplicationMetadata = new flac.metadata.ApplicationMetadata()
riffApplicationMetadata.id = 'riff'
riffApplicationMetadata.data = riffChunk.raw
riffChunks.push(riffApplicationMetadata)
}
// create encoder with the metadata block
const flacEncoder = new flac.FileEncoder({
file: output || 'out.flac',
compressionLevel: 9,
metadata: riffChunks,
})
Note that I could not test that properly, don't have anything to try this fine. This "code" gives you something like this:
If you would like to inspect further, I made a quick CodeSandbox https://codesandbox.io/p/sandbox/lively-bash-gw9jnh?file=%2Findex.js%3A76%2C38
I could not find any npm package that I liked to use for this sample (I have to say I just spend 10 minutes looking) so I made the code to read the chunks manually. Is not that complicated I have to say hehe. I hope this helps you find the solution to your issue.
On the other hand, I don't quite like the idea to have this kind of code around, which is not from flac API directly. I see the utility of it but I don't many people using it for their daily use. If you would like to keep this for your project, for me it's fine.
Anyway, I also don't mind to have it anyways if the code does not use any external dependency. Like an utils package inside the library 🤔 I would accept the PR. The only issue is I don't have time to maintain two versions for the library (2.x and 3.x), so it will only go to 3.x, sorry for that tho.
Thanks for raising the issue :)
from node-flac-bindings.
Thanks for your thoughtful comment and useful advice/examples.
Comparing the two files you generated in your codebox:
exiftool ./test/out.flac -G1
They appear to be different metadata. I will spend some time on this over the next few days and then report back my findings!
from node-flac-bindings.
Hello again! At least something is being read with that tool! That's something hehe
Good luck with the investigations. I am looking forward to your results. If you need some help, I may be able to assist you.
Also, take a look at flac's source code, something I did not think of yesterday to check: https://github.com/xiph/flac/blob/master/src/flac/foreign_metadata.c#L210 Maybe you see something useful in it.
from node-flac-bindings.
Related Issues (20)
- how to create metadata HOT 4
- Windows build errors HOT 11
- 24bit encoding HOT 7
- FLAC compressionLevel parameter is ignored HOT 5
- Miss check object on ptr HOT 1
- 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
- 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
- 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
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.