mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Add support for custom encoders & decoders
This commit is contained in:
+5
-1
@@ -43,8 +43,12 @@
|
||||
codec: 'aac',
|
||||
},
|
||||
*/
|
||||
video: {
|
||||
codec: 'avc',
|
||||
},
|
||||
audio: {
|
||||
discard: true
|
||||
codec: 'mp3',
|
||||
bitrate: 320000
|
||||
},
|
||||
trim: {
|
||||
start: 0,
|
||||
|
||||
+7
-4
@@ -22,15 +22,18 @@
|
||||
});
|
||||
|
||||
const audioTrack = await input.getPrimaryAudioTrack();
|
||||
const sink = new Metamuxer.EncodedAudioSampleSink(audioTrack);
|
||||
const sink = new Metamuxer.AudioDataSink(audioTrack);
|
||||
|
||||
const mediaSource = new Metamuxer.EncodedAudioSampleSource(await audioTrack.getCodec());
|
||||
const mediaSource = new Metamuxer.AudioDataSource({
|
||||
codec: 'mp3',
|
||||
bitrate: 192000
|
||||
});
|
||||
output.addAudioTrack(mediaSource);
|
||||
|
||||
output.start();
|
||||
|
||||
for await (const sample of sink.samples()) {
|
||||
await mediaSource.digest(sample);
|
||||
for await (const { data } of sink.data()) {
|
||||
await mediaSource.digest(data);
|
||||
}
|
||||
|
||||
await output.finalize();
|
||||
|
||||
Reference in New Issue
Block a user