merge background audio file

前端 未结 1 1980
天涯浪人
天涯浪人 2021-01-26 08:01

I have 2 audio files for primary and background music that I want to merge (not concatenate). The final audio file should be as long as the primary file, and if the background m

1条回答
  •  有刺的猬
    2021-01-26 08:33

    As a possible solution, why not detect if the length of the background file < length of the foreground file and then construct a background file which is a loop, if necessary? Then you can pass that into sox.

    You should be able to get the length from sndhdr (look at the frames count).

    As far as a python way of merging the streams, audioop.add may do what you need, although if you're merging two full volume sources, you might want to reduce the volume of one of them (try -12db as a start) if you're mixing music and not.

    More audio libraries can be found here.

    0 讨论(0)
提交回复
热议问题