arrow-left

All pages
gitbookPowered by GitBook
1 of 12

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

utilities

Flutter Sound Helpers API

isFFmpegAvailable()

hashtag
isFFmpegAvailable()

  • Dart API: isFFmpegAvailable()arrow-up-right

This verb is used to know during runtime if FFmpeg is linked with the App.

Example:

</div>

Flutter Sound Helpers API

pcmToWave()

hashtag
pcmToWave()

  • Dart API:

This verb is usefull to convert a Raw PCM file to a Wave file.

Flutter Sound Helpers API

getLastFFmpegReturnCode()

hashtag
getLastFFmpegReturnCode()

  • Dart API:

Flutter Sound Helpers API

ffMpegGetMediaInformation()

hashtag
ffMpegGetMediaInformation()

  • Dart API:

Flutter Sound Helpers API

waveToPCMBuffer()

hashtag
waveToPCMBuffer()

  • Dart API:

This verb is usefull to convert a Wave buffer to a Raw PCM buffer. Note that this verb is not asynchronous and does not return a Future.


        if ( await flutterSoundHelper.isFFmpegAvailable() )
        {
                Duration d = flutterSoundHelper.duration("$myFilePath/bar.wav");
        }

        Lorem ipsum ...
Dart
Javascript

It adds a Wave envelop to the PCM file, so that the file can be played back with startPlayer().

Note: the parameters numChannels and sampleRate are mandatory, and must match the actual PCM data. See herearrow-up-right a discussion about Raw PCM and WAVE file format.

Example:

Dart

Javascript

</div>

pcmToWave()arrow-up-right

        String inputFile = '$myInputPath/bar.pcm';
        var tempDir = await getTemporaryDirectory();
        String outpufFile = '${tempDir.path}/$foo.wav';
        await flutterSoundHelper.pcmToWave(inputFile: inputFile, outpoutFile: outputFile, numChannels: 1, sampleRate: 8000);
This simple verb is used to get the result of the last FFmpeg command

Example:

Dart

Javascript

</div>

getLastFFmpegReturnCode()arrow-up-right

        int result = await getLastFFmpegReturnCode();

        Lorem ipsum ...
This verb is used to get various informations on a file.

The informations got with FFmpegGetMediaInformation() are documented herearrow-up-right.

Example:

Dart

Javascript

</div>

ffMpegGetMediaInformation()arrow-up-right

        print( await getLastFFmpegCommandOutput() );

It removes the Wave envelop from the PCM buffer.

Example:

Dart

Javascript

</div>

waveToPCMBuffer()arrow-up-right

        Uint8List pcmBuffer flutterSoundHelper.waveToPCMBuffer(inputBuffer: aWaveBuffer);

        Lorem ipsum ...

        Lorem ipsum ...

        Map info = await flutterSoundHelper.FFmpegGetMediaInformation( uri );

Flutter Sound Helpers API

duration()

hashtag
duration()

  • Dart API: duration()arrow-up-right

This verb is used to get an estimation of the duration of a sound file. Be aware that it is just an estimation, based on the Codec used and the sample rate.

Note : this verb uses FFmpeg and is not available int the LITE flavor of Flutter Sound.

Example:

</div>

Flutter Sound Helpers API

executeFFmpegWithArguments()

hashtag
executeFFmpegWithArguments()

  • Dart API: executeFFmpegWithArguments()arrow-up-right

This verb is a wrapper for the great FFmpeg application. The command "man ffmpeg" (if you have installed ffmpeg on your computer) will give you many informations. If you do not have ffmpeg on your computer you will find easyly on internet many documentation on this great program.

Example:

</div>

Flutter Sound Helpers API

waveToPCM()

hashtag
waveToPCM()

  • Dart API: waveToPCM()arrow-up-right

This verb is usefull to convert a Wave file to a Raw PCM file.

It removes the Wave envelop from the PCM file.

Example:

</div>

Flutter Sound Helpers API

getLastFFmpegCommandOutput()

hashtag
getLastFFmpegCommandOutput()

  • Dart API: getLastFFmpegCommandOutput()arrow-up-right

This simple verb is used to get the output of the last FFmpeg command

Example:

</div>

Flutter Sound Helpers API

pcmToWaveBuffer()

hashtag
pcmToWaveBuffer()

  • Dart API: pcmToWaveBuffer()arrow-up-right

This verb is usefull to convert a Raw PCM buffer to a Wave buffer.

It adds a Wave envelop in front of the PCM buffer, so that the file can be played back with startPlayerFromBuffer().

Note: the parameters numChannels and sampleRate are mandatory, and must match the actual PCM data. a discussion about Raw PCM and WAVE file format.

Example:

</div>

Flutter Sound Helpers API

convertFile()

hashtag
convertFile()

  • Dart API:

This verb is useful to convert a sound file to a new format.


        Duration d = flutterSoundHelper.duration("$myFilePath/bar.wav");

        Lorem ipsum ...
Dart
Javascript

int rc = await flutterSoundHelper.executeFFmpegWithArguments
 ([
        '-loglevel',
        'error',
        '-y',
        '-i',
        infile,
        '-c:a',
        'copy',
        outfile,
]); // remux OGG to CAF
Dart
Javascript

        String inputFile = '$myInputPath/bar.pcm';
        var tempDir = await getTemporaryDirectory();
        String outpufFile = '${tempDir.path}/$foo.wav';
        await flutterSoundHelper.waveToPCM(inputFile: inputFile, outpoutFile: outputFile);

        Lorem ipsum ...
Dart
Javascript

        print( await getLastFFmpegCommandOutput() );

        Lorem ipsum ...
Dart
Javascript

        Uint8List myWavBuffer = await flutterSoundHelper.pcmToWaveBuffer(inputBuffer: myPCMBuffer, numChannels: 1, sampleRate: 8000);
See herearrow-up-right
Dart
Javascript
  • infile is the file path of the file you want to convert

  • codecin is the actual file format

  • outfile is the path of the file you want to create

  • codecout is the new file format

Be careful : outfile and codecout must be compatible. The output file extension must be a correct file extension for the new format.

Note : this verb uses FFmpeg and is not available int the LITE flavor of Flutter Sound.

Example:

Dart

Javascript

</div>

convertFile()arrow-up-right

        Lorem ipsum ...

        Lorem ipsum ...

        String inputFile = '$myInputPath/bar.wav';
        var tempDir = await getTemporaryDirectory();
        String outpufFile = '${tempDir.path}/$foo.mp3';
        await flutterSoundHelper.convertFile(inputFile, codec.pcm16WAV, outputFile, Codec.mp3)

        Lorem ipsum ...