将文件通过管道传输到不同的流
Piping a file to a different stream
我正在使用 growing-file
读取音频文件并将其通过管道传输到可写流,如下所示:
var GrowingFile = require('growing-file')
var audio = GrowingFile.open('test.wav')
audio.pipe(<some writable stream>);
几分钟后,我想更改流的传输位置。
我试图只创建第二个 audio.pipe(<new writable stream>)
但是这现在只写入两个流。我将如何去杀死第一个流?
不确定这是否是最佳解决方案,但这对我有用:
var GrowingFile = require('growing-file')
var unpipe = require('unpipe');
var audio = GrowingFile.open('test.wav')
audio.pipe(<some writable stream>);
//later in code
unpipe(audio);
audio.pipe(<some new writable stream>);
见readable.unpipe([destination])
var GrowingFile = require('growing-file')
var audio = GrowingFile.open('test.wav')
var writeableStream = <some writable stream>
audio.pipe(writeableStream);
setTimeout(() => {
audio.unpipe(writeableStream)
writeableStream = <some other writable stream>
audio.pipe(writeableStream)
}, 60000)
我正在使用 growing-file
读取音频文件并将其通过管道传输到可写流,如下所示:
var GrowingFile = require('growing-file')
var audio = GrowingFile.open('test.wav')
audio.pipe(<some writable stream>);
几分钟后,我想更改流的传输位置。
我试图只创建第二个 audio.pipe(<new writable stream>)
但是这现在只写入两个流。我将如何去杀死第一个流?
不确定这是否是最佳解决方案,但这对我有用:
var GrowingFile = require('growing-file')
var unpipe = require('unpipe');
var audio = GrowingFile.open('test.wav')
audio.pipe(<some writable stream>);
//later in code
unpipe(audio);
audio.pipe(<some new writable stream>);
见readable.unpipe([destination])
var GrowingFile = require('growing-file')
var audio = GrowingFile.open('test.wav')
var writeableStream = <some writable stream>
audio.pipe(writeableStream);
setTimeout(() => {
audio.unpipe(writeableStream)
writeableStream = <some other writable stream>
audio.pipe(writeableStream)
}, 60000)