T
T
toppi2020-12-10 21:29:34
go
toppi, 2020-12-10 21:29:34

How to create and merge audio in golang?

I have 400+ audio files where each is about 3-4 seconds long. And I need to either create an empty audio file of a certain period of time and directly insert my files into it, or combine all these files into one, but with the generation of empty intervals. The question is how to actually implement all this and preferably using Golang

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Mamonov, 2020-12-10
@toppi

If we talk about the implementation on Go - as an option...
1. create a file and encoder like here https://github.com/viert/go-lame
2. read your files in a loop using mp3 decoder, like here https://github.com/hajimehoshi/go-mp3/blob/master/...
and write their contents to the encoder
Where you need emptiness - try to record/generate 1sec or less silence and write it to the encoder when needed.
If the task just needs to be solved and it is not necessary to use Go - it can be solved using the `ffmpeg` console command like this:

ffmpeg file1.mp3 file2.mp3 silence1sec.mp3 silence1sec.mp3 output.mp3

If you still need to implement on Go - that is, at least two wrappers
https://github.com/giorgisio/goav
https://github.com/xfrr/goffmpeg
You can first make everything work from the console, and then " twist" wrappers

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question