Closed Tnemlec closed 2 years ago
Ok I fixed it sorry for trouble.
If someone have the same issue, split audio and video from the input and put it in the stream array. Put in kwargs you want both audio and video with: ffmpeg.KwArgs{"v": 1, "a": 1}
. This give me the following code:
files, err := ioutil.ReadDir("./videos")
if err != nil {
log.Fatalln(err)
}
//Mix them !
log.Println(files)
var files_stream []*ffmpeg.Stream
for _, file := range files {
in := ffmpeg.Input("./videos/" + file.Name())
files_stream = append(files_stream, in.Video())
files_stream = append(files_stream, in.Audio())
}
err = ffmpeg.Concat(files_stream, ffmpeg.KwArgs{"v": 1, "a": 1}).Output("./results/final.mp4").OverWriteOutput().ErrorToStdOut().Run()
if err != nil {
log.Fatalln(err)
}
log.Println("Done ! check here: ./results/final.mp4")
Hope this will help, thanks again for the library, great little project to learn golang π¨βπ
I also had problems with this task. Here is my solution:
File: list.txt
file 'video-0.mp4'
file 'video-1.mp4'
concat.go
ffmpeg.Input("list.txt", ffmpeg.KwArgs{"f": "concat"}).Output(
"temp/final.mp4", ffmpeg.KwArgs{"c": "copy"},
).OverWriteOutput().ErrorToStdOut().Run()
If you use the library method, you get videos without sound. I guess you can somehow configure the library method to make it work, but I haven't figured it out. I hope the author will update the documentation.
Hello,
I want to concatenate two videos "1.mp4" and "2.mp4" using
ffmpeg.Concat(streams)
function, it gives me the concatenation of the videos without sound wich is problematic.After some research, I found out that the following command works:
ffmpeg -i 1.mp4 -i 2.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" ./results/final.mp4 -y
However impossible for me to figure out how to create this command with this library. Here is my code:
In the ffmpeg output I can clearly see both Audio and Video stream for both inputs + the top command managed to handle them so I don't think the problem come from the videos.
Thank you for your help π