Stream overlapping audio files to Chromecast Audio

醉酒当歌 提交于 2019-12-05 07:03:52

So there are two parts to your problem

  • Mixing the audios using different options
  • Stream that mixed response from a webserver

I can help you with the later part and you need to figure out the first part yourself

Below is a sample nodejs script. Run it create a directory and run

npm init
npm install fluent-ffmpeg express

and then save the below file

server.js

var ff = require('fluent-ffmpeg');
var express = require('express')
var app = express()

app.get('/merged', (req, res) => {
    res.contentType('mp3');
    // res.header("Transfer-Encoding", "chunked")
    command = ff()
        .input("1.mp3")
        .input("2.mp3")
        .input("3.mp3")
        .input("4.mp3")
        .complexFilter(`[1]adelay=2|5[b];
        [2]adelay=10|12[c];
        [3]adelay=4|6[d];
        [0][b][c][d]amix=4`)
        .outputOptions(["-f", "flv"])
    ;

    command.on('end', () => {
        console.log('Processed finished')
        // res.end()
    })
    command.pipe(res, {end: true});
    command.on('error', function(err, stdout, stderr) {
        console.log('ffmpeg stdout: ' + stdout);
        console.log('ffmpeg stderr: ' + stderr);
    });

})

app.listen(9090)

Run it using below command

node server.js

Now in VLC open http://localhost:9090/merged

Now for your requirement the below part will change

        .complexFilter(`[1]adelay=2|5[b];
        [2]adelay=10|12[c];
        [3]adelay=4|6[d];
        [0][b][c][d]amix=4`)

But I am no ffmpeg expert to guide you around that area. Perhaps that calls for another question or taking lead from lot of existing SO threads

ffmpeg - how to merge multiple audio with time offset into a video?

How to merge two audio files while retaining correct timings with ffmpeg

ffmpeg mix audio at specific time

https://superuser.com/questions/850527/combine-three-videos-between-specific-time-using-ffmpeg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!