This repository was archived by the owner on Jun 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
This repository was archived by the owner on Jun 23, 2025. It is now read-only.
Using FFmpeg without write/read file path? #808
Copy link
Copy link
Closed
Description
My primary objective is to record audio and alter its pitch in real-time. The steps I'm currently working on are as follows:
-
Recording:
For recording, I'm using this package flutter sound and streaming audio data in pcm16 format (Uint8List). -
Auto Pitch:
To achieve pitch shifting, I'm using this ffmpeg kit. The process involves several steps:- Write the audio data to files.
- execute FFmpeg arguments for applying the desired pitch.
- Read the output audio data from file.
- Play output audio
player.feedFromStream(outputAudio)usingFlutterSoundPlayerfrom flutter sound
I have successfully accomplished this, but the real-time pitch shifting experience is not as smooth as I expected. This is likely too much steps used affecting real time performance.
i've try to use ffmpeg using the Dart Process API, but seems not luck.
Future<Uint8List> testAudio({required Uint8List audioData}) async {
final additionalArguments = [
'-af',
'volume=1' // example argument
];
final ffmpegProcess = await io.Process.start(
'ffmpeg',
[
'-i', 'pipe:0', // input
...additionalArguments,
'-f', 'wav', 'pipe:1', // output
],
mode: io.ProcessStartMode.detachedWithStdio,
runInShell: true,
);
ffmpegProcess.stdin.add(audioData);
await ffmpegProcess.stdin.flush();
await ffmpegProcess.stdin.close();
final bytes = await ffmpegProcess.stdout.toBytes();
ffmpegProcess.kill();
return Uint8List.fromList(bytes);
}
extension StreamToBytes on Stream<List<int>> {
Future<List<int>> toBytes() async {
final chunks = await toList();
final bytesBuilder = BytesBuilder();
for (final chunk in chunks) {
bytesBuilder.add(chunk);
}
return bytesBuilder.takeBytes();
}
}
How i can filter audio in real-time using ffmpeg and get result in Uint8list? I mean, if using ffmpeg with path to write/read, it too much step to get result in realtime. any solution for this?
ersha80, Azramis and Mamena2020
Metadata
Metadata
Assignees
Labels
No labels