Giter VIP home page Giter VIP logo

flutter_lame's People

Contributors

bestowl avatar

Stargazers

 avatar

Watchers

 avatar  avatar

flutter_lame's Issues

High memory consumption when the encoder is called.

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;

iOS环境下,pcm转mp3后,会有哒哒的声音

经过详细的测试发现:
录制的pcm流是正常的,但是经过mp3编码后会出现哒哒的声音。
如果把最初的2800帧流截取掉,就能消除哒哒的杂音。
但是上述的方法会出现新的问题,当播放器初次播放的时候,播放到一半左右的位置就自动暂停了,下一次播放就是正常播放到结束。
上述问题只在iOS环境下出现,Android环境正常。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.