@lumen5/beamcoder 0.0.21 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/.circleci/config.yml +0 -41
- package/.circleci/images/testbeam10-4.1/Dockerfile +0 -12
- package/.circleci/test_image/Dockerfile +0 -14
- package/.circleci/test_image/build.md +0 -13
- package/.github/workflows/prebuild.yml +0 -118
- package/examples/encode_h264.js +0 -92
- package/examples/jpeg_app.js +0 -55
- package/examples/jpeg_filter_app.js +0 -101
- package/examples/make_mp4.js +0 -123
- package/images/beamcoder_small.jpg +0 -0
- package/prebuilds/@lumen5/beamcoder-v0.0.21-node-v127-darwin-arm64.tar.gz +0 -0
- package/prebuilds/@lumen5/beamcoder-v0.0.21-node-v127-linux-x64.tar.gz +0 -0
- package/scratch/decode_aac.js +0 -38
- package/scratch/decode_avci.js +0 -50
- package/scratch/decode_hevc.js +0 -38
- package/scratch/decode_pcm.js +0 -39
- package/scratch/make_a_mux.js +0 -68
- package/scratch/muxer.js +0 -74
- package/scratch/read_wav.js +0 -35
- package/scratch/simple_mux.js +0 -39
- package/scratch/stream_avci.js +0 -127
- package/scratch/stream_mp4.js +0 -78
- package/scratch/stream_mux.js +0 -47
- package/scratch/stream_pcm.js +0 -82
- package/scratch/stream_wav.js +0 -62
- package/test/codecParamsSpec.js +0 -148
- package/test/decoderSpec.js +0 -56
- package/test/demuxerSpec.js +0 -41
- package/test/encoderSpec.js +0 -69
- package/test/filtererSpec.js +0 -47
- package/test/formatSpec.js +0 -343
- package/test/frameSpec.js +0 -145
- package/test/introspectionSpec.js +0 -73
- package/test/muxerSpec.js +0 -34
- package/test/packetSpec.js +0 -122
package/scratch/decode_hevc.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
|
|
3
|
-
Copyright (C) 2019 Streampunk Media Ltd.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
https://www.streampunk.media/ mailto:furnace@streampunk.media
|
|
19
|
-
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const beamcoder = require('../index.js');
|
|
23
|
-
|
|
24
|
-
async function run() {
|
|
25
|
-
let demuxer = await beamcoder.demuxer('../media/bbb_1080p_c.ts');
|
|
26
|
-
console.log(demuxer);
|
|
27
|
-
let decoder = await beamcoder.decoder({ name: 'hevc' });
|
|
28
|
-
for ( let x = 0 ; x < 100 ; x++ ) {
|
|
29
|
-
let packet = await demuxer.read();
|
|
30
|
-
if (packet.stream_index == 0) {
|
|
31
|
-
// console.log(packet);
|
|
32
|
-
let frames = await decoder.decode(packet); // eslint-disable-line
|
|
33
|
-
// console.log(frames);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
run();
|
package/scratch/decode_pcm.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
|
|
3
|
-
Copyright (C) 2019 Streampunk Media Ltd.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
https://www.streampunk.media/ mailto:furnace@streampunk.media
|
|
19
|
-
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const beamcoder = require('../index.js');
|
|
23
|
-
|
|
24
|
-
async function run() {
|
|
25
|
-
let demuxer = await beamcoder.demuxer('../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf');
|
|
26
|
-
console.log(demuxer.streams[1]);
|
|
27
|
-
let decoder = await beamcoder.decoder({ demuxer: demuxer, stream_index : 1 });
|
|
28
|
-
console.log(decoder);
|
|
29
|
-
for ( let x = 0 ; x < 100 ; x++ ) {
|
|
30
|
-
let packet = await demuxer.read();
|
|
31
|
-
if (packet.stream == 1) {
|
|
32
|
-
//console.log(packet);
|
|
33
|
-
let frames = await decoder.decode(packet);
|
|
34
|
-
console.log(frames.frames);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
run();
|
package/scratch/make_a_mux.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
|
|
3
|
-
Copyright (C) 2019 Streampunk Media Ltd.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
https://www.streampunk.media/ mailto:furnace@streampunk.media
|
|
19
|
-
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const beamcoder = require('../index.js');
|
|
23
|
-
|
|
24
|
-
async function run() {
|
|
25
|
-
let demuxer = await beamcoder.demuxer('../media/sound/BBCNewsCountdown.wav');
|
|
26
|
-
console.log(demuxer.streams[0].codecpar);
|
|
27
|
-
let muxer = beamcoder.muxer({ filename: 'file:test.wav' });
|
|
28
|
-
let stream = muxer.newStream({
|
|
29
|
-
name: 'pcm_s16le',
|
|
30
|
-
time_base: [1, 48000 ],
|
|
31
|
-
interleaved: false, });
|
|
32
|
-
Object.assign(stream.codecpar, {
|
|
33
|
-
channels: 2,
|
|
34
|
-
sample_rate: 48000,
|
|
35
|
-
format: 's16',
|
|
36
|
-
channel_layout: 'stereo',
|
|
37
|
-
block_align: 4,
|
|
38
|
-
bits_per_coded_sample: 16,
|
|
39
|
-
bit_rate: 48000 * 4 * 8
|
|
40
|
-
});
|
|
41
|
-
/* let stream = muxer.newStream({
|
|
42
|
-
name: 'pcm_s16le',
|
|
43
|
-
time_base: [1, 48000 ],
|
|
44
|
-
codecpar: {
|
|
45
|
-
name: 'pcm_s16le',
|
|
46
|
-
channels: 2,
|
|
47
|
-
sample_rate: 48000,
|
|
48
|
-
format: 's16',
|
|
49
|
-
channel_layout: 'stereo',
|
|
50
|
-
block_align: 4,
|
|
51
|
-
bits_per_coded_sample: 16,
|
|
52
|
-
bit_rate: 48000*4
|
|
53
|
-
}
|
|
54
|
-
}); */
|
|
55
|
-
console.log(stream.codecpar);
|
|
56
|
-
// stream.time_base = demuxer.streams[0].time_base;
|
|
57
|
-
// stream.codecpar = demuxer.streams[0].codecpar;
|
|
58
|
-
await muxer.openIO({ options: { blocksize: 8192 }}).then(console.log);
|
|
59
|
-
await muxer.writeHeader({ options: { write_bext: true, write_peak: 'on', peak_format: 2 }}).then(console.log);
|
|
60
|
-
let packet = {};
|
|
61
|
-
for ( let x = 0 ; x < 100 && packet !== null ; x++ ) {
|
|
62
|
-
packet = await demuxer.read();
|
|
63
|
-
await muxer.writeFrame(packet);
|
|
64
|
-
}
|
|
65
|
-
await muxer.writeTrailer();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
run();
|
package/scratch/muxer.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
|
|
3
|
-
Copyright (C) 2019 Streampunk Media Ltd.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
https://www.streampunk.media/ mailto:furnace@streampunk.media
|
|
19
|
-
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
// Work in progress
|
|
23
|
-
|
|
24
|
-
const beamcoder = require('../index.js');
|
|
25
|
-
|
|
26
|
-
const STREAM_FRAME_RATE = 25;
|
|
27
|
-
|
|
28
|
-
function allocAudioFrame(sampleFormat, channelLayout, sampleRate, nbSamples) {
|
|
29
|
-
|
|
30
|
-
return beamcoder.frame({
|
|
31
|
-
format: sampleFormat,
|
|
32
|
-
channel_layout: channelLayout,
|
|
33
|
-
sample_rate: sampleRate,
|
|
34
|
-
nb_samples: nbSamples
|
|
35
|
-
}).alloc();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function allocPicture(pixelFmt, width, height) { // eslint-disable-line
|
|
39
|
-
|
|
40
|
-
return beamcoder.frame({
|
|
41
|
-
format: pixelFmt,
|
|
42
|
-
width: width,
|
|
43
|
-
height: height
|
|
44
|
-
}).alloc();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function addStream(stream, muxer, codecID) { // eslint-disable-line
|
|
48
|
-
let codec = await beamcoder.encoder({ codec_id: codecID });
|
|
49
|
-
|
|
50
|
-
stream.st = muxer.newStream();
|
|
51
|
-
stream.enc = codec;
|
|
52
|
-
switch (codec.media_type) {
|
|
53
|
-
case 'video':
|
|
54
|
-
codec.setParameters({
|
|
55
|
-
codec_id: codecID,
|
|
56
|
-
bit_rate: 400000,
|
|
57
|
-
width: 352,
|
|
58
|
-
height: 288,
|
|
59
|
-
time_base: [1, STREAM_FRAME_RATE],
|
|
60
|
-
gop_size: 12
|
|
61
|
-
});
|
|
62
|
-
break;
|
|
63
|
-
case 'audio':
|
|
64
|
-
break;
|
|
65
|
-
default:
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function run() {
|
|
71
|
-
allocAudioFrame('s32p', 'stereo', 48000, 1920);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
run();
|
package/scratch/read_wav.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
|
|
3
|
-
Copyright (C) 2019 Streampunk Media Ltd.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
https://www.streampunk.media/ mailto:furnace@streampunk.media
|
|
19
|
-
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const beamcoder = require('../index.js');
|
|
23
|
-
|
|
24
|
-
async function run() {
|
|
25
|
-
let demuxer = await beamcoder.demuxer('../media/sound/BBCNewsCountdown.wav');
|
|
26
|
-
let packet = {};
|
|
27
|
-
for ( let x = 0 ; x < 100 && packet !== null ; x++ ) {
|
|
28
|
-
packet = await demuxer.read();
|
|
29
|
-
console.log(x, packet);
|
|
30
|
-
}
|
|
31
|
-
console.log(await demuxer.seek({ frame : 120 }));
|
|
32
|
-
console.log(await demuxer.read());
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
run();
|
package/scratch/simple_mux.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
|
|
3
|
-
Copyright (C) 2019 Streampunk Media Ltd.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
https://www.streampunk.media/ mailto:furnace@streampunk.media
|
|
19
|
-
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
|
|
20
|
-
*/
|
|
21
|
-
const beamcoder = require('../index.js');
|
|
22
|
-
|
|
23
|
-
async function run() {
|
|
24
|
-
let demuxer = await beamcoder.demuxer('../media/sound/BBCNewsCountdown.wav');
|
|
25
|
-
let muxer = beamcoder.muxer({ filename: 'file:test.wav' });
|
|
26
|
-
let stream = muxer.newStream(demuxer.streams[0]); // eslint-disable-line
|
|
27
|
-
// stream.time_base = demuxer.streams[0].time_base;
|
|
28
|
-
// stream.codecpar = demuxer.streams[0].codecpar;
|
|
29
|
-
await muxer.openIO();
|
|
30
|
-
await muxer.writeHeader();
|
|
31
|
-
let packet = {};
|
|
32
|
-
for ( let x = 0 ; x < 100 && packet !== null ; x++ ) {
|
|
33
|
-
packet = await demuxer.read();
|
|
34
|
-
await muxer.writeFrame(packet);
|
|
35
|
-
}
|
|
36
|
-
await muxer.writeTrailer();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
run();
|
package/scratch/stream_avci.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
|
|
3
|
-
Copyright (C) 2019 Streampunk Media Ltd.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
https://www.streampunk.media/ mailto:furnace@streampunk.media
|
|
19
|
-
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const beamcoder = require('../index.js');
|
|
23
|
-
const fs = require('fs');
|
|
24
|
-
// const util = require('util');
|
|
25
|
-
|
|
26
|
-
async function run() {
|
|
27
|
-
// let demuxer = await createDemuxer('../../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf');
|
|
28
|
-
let demuxerStream = beamcoder.demuxerStream({ highwaterMark: 65536 });
|
|
29
|
-
fs.createReadStream('../../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf').pipe(demuxerStream);
|
|
30
|
-
let demuxer = await demuxerStream.demuxer({});
|
|
31
|
-
// console.log(demuxer);
|
|
32
|
-
|
|
33
|
-
let decoder = await beamcoder.decoder({ name: 'h264' });
|
|
34
|
-
// console.log(decoder);
|
|
35
|
-
|
|
36
|
-
const vidStream = demuxer.streams[0];
|
|
37
|
-
let filterer = await beamcoder.filterer({
|
|
38
|
-
filterType: 'video',
|
|
39
|
-
inputParams: [
|
|
40
|
-
{
|
|
41
|
-
name: 'in0:v',
|
|
42
|
-
width: vidStream.codecpar.width,
|
|
43
|
-
height: vidStream.codecpar.height,
|
|
44
|
-
pixelFormat: vidStream.codecpar.format,
|
|
45
|
-
timeBase: vidStream.time_base,
|
|
46
|
-
pixelAspect: vidStream.sample_aspect_ratio
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: 'in1:v',
|
|
50
|
-
width: vidStream.codecpar.width,
|
|
51
|
-
height: vidStream.codecpar.height,
|
|
52
|
-
pixelFormat: vidStream.codecpar.format,
|
|
53
|
-
timeBase: vidStream.time_base,
|
|
54
|
-
pixelAspect: vidStream.sample_aspect_ratio
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
outputParams: [
|
|
58
|
-
{
|
|
59
|
-
name: 'out0:v',
|
|
60
|
-
pixelFormat: 'yuv422p'
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
filterSpec: '[in0:v] scale=1280:720 [left]; [in1:v] scale=640:360 [right]; [left][right] overlay=format=auto:x=640 [out0:v]'
|
|
64
|
-
});
|
|
65
|
-
// console.log(filterer.graph);
|
|
66
|
-
// console.log(util.inspect(filterer.graph, {depth: null}));
|
|
67
|
-
console.log(filterer.graph.dump());
|
|
68
|
-
|
|
69
|
-
// width = '1000';
|
|
70
|
-
// const scaleFilter = filterer.graph.filters.find(f => 'scale' === f.filter.name);
|
|
71
|
-
// scaleFilter.priv = { width: 1000 };
|
|
72
|
-
// console.log(util.inspect(scaleFilter, {depth: null}));
|
|
73
|
-
|
|
74
|
-
// const overlayFilter = filterer.graph.filters.find(f => 'overlay' === f.filter.name);
|
|
75
|
-
// overlayFilter.priv = { x: 100, y: 100 };
|
|
76
|
-
// console.log(util.inspect(overlayFilter, {depth: null}));
|
|
77
|
-
|
|
78
|
-
let encParams = {
|
|
79
|
-
name: 'libx264',
|
|
80
|
-
width: 1280,
|
|
81
|
-
height: 720,
|
|
82
|
-
// bit_rate: 10000000,
|
|
83
|
-
time_base: [1, 25],
|
|
84
|
-
framerate: [25, 1],
|
|
85
|
-
// gop_size: 50,
|
|
86
|
-
// max_b_frames: 1,
|
|
87
|
-
pix_fmt: 'yuv422p',
|
|
88
|
-
priv_data: {
|
|
89
|
-
crf: 23
|
|
90
|
-
// preset: 'slow',
|
|
91
|
-
// profile: 'high422',
|
|
92
|
-
// level: '4.2'
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
let encoder = beamcoder.encoder(encParams);
|
|
97
|
-
// console.log(encoder);
|
|
98
|
-
|
|
99
|
-
let outFile = fs.createWriteStream('wibble.h264');
|
|
100
|
-
|
|
101
|
-
// await demuxer.seek({ frame: 4200, stream_index: 0});
|
|
102
|
-
|
|
103
|
-
let packet = {};
|
|
104
|
-
for ( let x = 0 ; x < 10 && packet !== null; x++ ) {
|
|
105
|
-
packet = await demuxer.read();
|
|
106
|
-
if (packet.stream_index == 0) {
|
|
107
|
-
// console.log(packet);
|
|
108
|
-
let frames = await decoder.decode(packet);
|
|
109
|
-
// console.log(frames);
|
|
110
|
-
let filtFrames = await filterer.filter([
|
|
111
|
-
{ name: 'in0:v', frames: frames.frames },
|
|
112
|
-
{ name: 'in1:v', frames: frames.frames },
|
|
113
|
-
]);
|
|
114
|
-
// console.log(filtFrames);
|
|
115
|
-
|
|
116
|
-
let packets = await encoder.encode(filtFrames[0].frames[0]);
|
|
117
|
-
// console.log(x, packets.totalTime);
|
|
118
|
-
packets.packets.forEach(x => outFile.write(x.data));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
let frames = await decoder.flush();
|
|
122
|
-
console.log('flush', frames.total_time, frames.frames.length);
|
|
123
|
-
|
|
124
|
-
demuxerStream.destroy();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
run().catch(console.error);
|
package/scratch/stream_mp4.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
|
|
3
|
-
Copyright (C) 2019 Streampunk Media Ltd.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
https://www.streampunk.media/ mailto:furnace@streampunk.media
|
|
19
|
-
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const beamcoder = require('../index.js');
|
|
23
|
-
|
|
24
|
-
async function run() {
|
|
25
|
-
const urls = [ 'file:../../Media/big_buck_bunny_1080p_h264.mov' ];
|
|
26
|
-
const spec = { start: 0, end: 24 };
|
|
27
|
-
|
|
28
|
-
const params = {
|
|
29
|
-
video: [
|
|
30
|
-
{
|
|
31
|
-
sources: [
|
|
32
|
-
{ url: urls[0], ms: spec, streamIndex: 0 }
|
|
33
|
-
],
|
|
34
|
-
filterSpec: '[in0:v] scale=1280:720, colorspace=all=bt709 [out0:v]',
|
|
35
|
-
streams: [
|
|
36
|
-
{ name: 'h264', time_base: [1, 90000],
|
|
37
|
-
codecpar: {
|
|
38
|
-
width: 1280, height: 720, format: 'yuv422p', color_space: 'bt709',
|
|
39
|
-
sample_aspect_ratio: [1, 1]
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
],
|
|
45
|
-
audio: [
|
|
46
|
-
{
|
|
47
|
-
sources: [
|
|
48
|
-
{ url: urls[0], ms: spec, streamIndex: 2 }
|
|
49
|
-
],
|
|
50
|
-
filterSpec: '[in0:a] aformat=sample_fmts=fltp:channel_layouts=mono [out0:a]',
|
|
51
|
-
streams: [
|
|
52
|
-
{ name: 'aac', time_base: [1, 90000],
|
|
53
|
-
codecpar: {
|
|
54
|
-
sample_rate: 48000, format: 'fltp', frame_size: 1024,
|
|
55
|
-
channels: 1, channel_layout: 'mono'
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
out: {
|
|
62
|
-
formatName: 'mp4',
|
|
63
|
-
url: 'file:temp.mp4'
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
await beamcoder.makeSources(params);
|
|
68
|
-
const beamStreams = await beamcoder.makeStreams(params);
|
|
69
|
-
|
|
70
|
-
await beamStreams.run();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
console.log('Running mp4 maker');
|
|
74
|
-
let start = Date.now();
|
|
75
|
-
run()
|
|
76
|
-
.then(() => console.log(`Finished ${Date.now() - start}ms`))
|
|
77
|
-
.catch(console.error);
|
|
78
|
-
|
package/scratch/stream_mux.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
|
|
3
|
-
Copyright (C) 2019 Streampunk Media Ltd.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
https://www.streampunk.media/ mailto:furnace@streampunk.media
|
|
19
|
-
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const beamcoder = require('../index.js');
|
|
23
|
-
const fs = require('fs');
|
|
24
|
-
|
|
25
|
-
async function run() {
|
|
26
|
-
let demuxer = await beamcoder.demuxer('../../media/sound/BBCNewsCountdown.wav');
|
|
27
|
-
|
|
28
|
-
let muxerStream = beamcoder.muxerStream({ highwaterMark: 65536 });
|
|
29
|
-
muxerStream.pipe(fs.createWriteStream('test.wav'));
|
|
30
|
-
|
|
31
|
-
let muxer = muxerStream.muxer({ format_name: 'wav' });
|
|
32
|
-
let stream = muxer.newStream(demuxer.streams[0]); // eslint-disable-line
|
|
33
|
-
// stream.time_base = demuxer.streams[0].time_base;
|
|
34
|
-
// stream.codecpar = demuxer.streams[0].codecpar;
|
|
35
|
-
await muxer.openIO();
|
|
36
|
-
|
|
37
|
-
await muxer.writeHeader();
|
|
38
|
-
let packet = {};
|
|
39
|
-
for ( let x = 0 ; x < 10000 && packet !== null ; x++ ) {
|
|
40
|
-
packet = await demuxer.read();
|
|
41
|
-
if (packet)
|
|
42
|
-
await muxer.writeFrame(packet);
|
|
43
|
-
}
|
|
44
|
-
await muxer.writeTrailer();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
run();
|
package/scratch/stream_pcm.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Aerostat Beam Coder - Node.js native bindings for FFmpeg.
|
|
3
|
-
Copyright (C) 2019 Streampunk Media Ltd.
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify
|
|
6
|
-
it under the terms of the GNU General Public License as published by
|
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
(at your option) any later version.
|
|
9
|
-
|
|
10
|
-
This program is distributed in the hope that it will be useful,
|
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
GNU General Public License for more details.
|
|
14
|
-
|
|
15
|
-
You should have received a copy of the GNU General Public License
|
|
16
|
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
-
|
|
18
|
-
https://www.streampunk.media/ mailto:furnace@streampunk.media
|
|
19
|
-
14 Ormiscaig, Aultbea, Achnasheen, IV22 2JJ U.K.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const beamcoder = require('../index.js');
|
|
23
|
-
const fs = require('fs');
|
|
24
|
-
const util = require('util'); // eslint-disable-line
|
|
25
|
-
|
|
26
|
-
async function run() {
|
|
27
|
-
let demuxerStream = beamcoder.demuxerStream({ highwaterMark: 65536 });
|
|
28
|
-
// fs.createReadStream('../../media/dpp/AS11_DPP_HD_EXAMPLE_1.mxf').pipe(demuxerStream);
|
|
29
|
-
fs.createReadStream('../../media/sound/BBCNewsCountdown.wav').pipe(demuxerStream);
|
|
30
|
-
|
|
31
|
-
let demuxer = await demuxerStream.demuxer();
|
|
32
|
-
console.log(demuxer.streams);
|
|
33
|
-
|
|
34
|
-
let decoder = await beamcoder.decoder({ demuxer: demuxer, stream_index : 0 });
|
|
35
|
-
// console.log(decoder);
|
|
36
|
-
|
|
37
|
-
const audStream = demuxer.streams[0];
|
|
38
|
-
let filterer = await beamcoder.filterer({
|
|
39
|
-
filterType: 'audio',
|
|
40
|
-
inputParams: [
|
|
41
|
-
{
|
|
42
|
-
name: '0:a',
|
|
43
|
-
sampleRate: audStream.codecpar.sample_rate,
|
|
44
|
-
sampleFormat: audStream.codecpar.format,
|
|
45
|
-
channelLayout: 'stereo', //audStream.codecpar.channel_layout,
|
|
46
|
-
timeBase: audStream.time_base
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
outputParams: [
|
|
50
|
-
{
|
|
51
|
-
name: 'out0:a',
|
|
52
|
-
sampleRate: 8000,
|
|
53
|
-
sampleFormat: 's16',
|
|
54
|
-
channelLayout: 'stereo'
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
filterSpec: '[0:a] aresample=8000, aformat=sample_fmts=s16:channel_layouts=stereo [out0:a]'
|
|
58
|
-
});
|
|
59
|
-
// console.log(filterer.graph);
|
|
60
|
-
// console.log(util.inspect(filterer.graph.filters[2], {depth: null}));
|
|
61
|
-
console.log(filterer.graph.dump());
|
|
62
|
-
|
|
63
|
-
// const abuffersink = filterer.graph.filters.find(f => 'abuffersink' === f.filter.name);
|
|
64
|
-
// console.log(util.inspect(abuffersink, {depth: null}));
|
|
65
|
-
|
|
66
|
-
let packet = {};
|
|
67
|
-
for ( let x = 0 ; x < 10000 && packet !== null ; x++ ) {
|
|
68
|
-
packet = await demuxer.read();
|
|
69
|
-
if (packet && packet.stream_index == 0) {
|
|
70
|
-
// console.log(packet);
|
|
71
|
-
let frames = await decoder.decode(packet);
|
|
72
|
-
// console.log(frames);
|
|
73
|
-
|
|
74
|
-
let filtFrames = await filterer.filter([ // eslint-disable-line
|
|
75
|
-
{ name: '0:a', frames: frames.frames }
|
|
76
|
-
]);
|
|
77
|
-
// console.log(filtFrames);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
run().catch(console.error);
|