最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - Can Nodejs fluent-ffmpeg process opus file stream in async way? - Stack Overflow

programmeradmin1浏览0评论

What I want to do:

  1. load a large opus file
  2. processing it using fluent-ffmpeg
  3. output a stream for further use (realtime output is required)

Runnable codes(file path needs to be changed):

const fs = require('fs');
const fluentffmpeg = require('fluent-ffmpeg');
var stream=fs.createReadStream("d:/PD_maid/music_temp/YTTemp/How many times do we have to teach you this lesson old man! (Cafe de touhou 1-8 albums)[RY7FpB9BZH4].opus")
var ffmpeg_audio_stream_C = fluentffmpeg(stream)

var streamOpt;
ffmpeg_audio_stream_C
    .toFormat('hls')
    .audioChannels(2)
    .audioFrequency(48000)
    .audioBitrate('1536k');

ffmpeg_audio_stream_C.on("error", (error) => {
    console.log("ffmpegErr" + error);
});
streamOpt = ffmpeg_audio_stream_C.pipe();

stream.on("data", (c) => {
    console.log("inp got data")
})
streamOpt.on("data", (c) => {
    console.log("Opt got data")
})

streamOpt.pipe(fs.createWriteStream("d:/PD_maid/music_temp/YTTemp/How many times do we have to teach you this lesson old man! (Cafe de touhou 1-8 albums)[RY7FpB9BZH4].hls"))

Expected result:

inp got data
inp got data
Opt got data
inp got data
Opt got data
......

And the output file should grow while processing the file

Result irl:

Lot of "inp got data" in several hours (memory usage growing here).

And Lot of "Opt got data" in a min after that.

It will have the expected result if the input is a .webm format file.

发布评论

评论列表(0)

  1. 暂无评论