bestowl / flutter_lame Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU Lesser General Public License v3.0
License: GNU Lesser General Public License v3.0
In my application, I am converting a WAV file to MP3 similarly to the example, but I have noticed a very high growth in memory consumption every time the encoder is initialized.
My app without performing any action consumes 19MB of memory, but every time I initialize the encoder, this memory increases 20MB more.
That is, if I start with a constant consumption of 19MB, when I use the encoder, it increases to 35MB, then 54MB and so on.
Even if I call the garbage collector, the resources that occupy the memory are not released.
Usage:
var encoder = LameMp3Encoder(); //only this line causes the increase in consumption
IOSink? sink;
final String outputFilePath = '$defaultPath/$fileName.mp3';
debugPrint(outputFilePath);
final wav = await compute(Wav.readFile, inputFile.path);
wav.toMono();
final File f = File(outputFilePath);
sink = f.openWrite();
encoder = LameMp3Encoder(
sampleRate: wav.samplesPerSecond,
numChannels: wav.channels.length,
bitRate: 30);
final left = wav.channels[0];
Float64List? right;
if (wav.channels.length > 1) {
right = wav.channels[1];
}
//Write file
for (int i = 0; i < left.length; i += wav.samplesPerSecond) {
final int endIndex = i + wav.samplesPerSecond;
final mp3Frame = await encoder.encodeDouble(
leftChannel:
left.sublist(i, endIndex < left.length ? endIndex : left.length),
rightChannel: right?.sublist(
i, endIndex < right.length ? endIndex : right.length),
);
sink.add(mp3Frame);
}
sink.add(await encoder.flush());
await inputFile.delete();
debugPrint("Finished");
readyAudioController.sink.add(true);
recorder.closeRecorder();
return true;
i have mp3 file binary stream and i need convert to PCM format to play realtime.
Can you add decode feature?
经过详细的测试发现:
录制的pcm流是正常的,但是经过mp3编码后会出现哒哒的声音。
如果把最初的2800帧流截取掉,就能消除哒哒的杂音。
但是上述的方法会出现新的问题,当播放器初次播放的时候,播放到一半左右的位置就自动暂停了,下一次播放就是正常播放到结束。
上述问题只在iOS环境下出现,Android环境正常。
flutter run
Lexical or Preprocessor Issue (Xcode): 'util.h' file not found
.pub-cache/hosted/pub.flutter-io.cn/flutter_lame-1.0.2/ios/Classes/libmp3lame/vector/xmm_quantize_sub.c:29:9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.