dsideal2015
dsideal2015
2018-10-10 06:43

如何在Linux中使用ffmpeg使用命令行将两个WAV缝合在一起?

已采纳

I have installed ffmpeg on debian and I tried the two command lines. There are two files under the same directory, they are first.wav and second.wav The first method is to create a txt file, inside a.txt, they are

file 'first.wav'
file 'second.wav'

I have run

ffmpeg -f concat -i a.txt -c copy final.wav

then I run it, it could work fine. But I want to try another method, which is

ffmpeg -i "concat:first.wav|second.wav" -c copy final2.wav

there is not error with the sdcond command line, but it only capture the first file and the length of final2.wav is almost same as first.wav. File second.wav is not stitched at all. As I am using golang to execute the command line, I want to use

cmd := exec.Command("ffmpeg",args)

to stitch the medias together, I can read all the media files into an array, but this API cannot work for the array, so I want to stitch the files together to

"concat:file1.wav|file2.wav|file3.wav|......"

in this case it could be easy to stitch the files together and I do not need to loop the cmd. like

cmd = exec.Command("ffmpeg","-i","concat:first.wav|second.wav|third.wav|......","-c","copy","final2.wav")

I do not want to create any extra files like a.txt file as I need to delete it later and this may also touch the permission. So is there any possible solution for the second command line?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dongwei1263 dongwei1263 3年前

    Try this one

    ffmpeg -i 1.wav -i 2.wav -i 3.wav ...... -i {n}.wav -filter_complex '[0:0][1:0]......[{n-1}:0]concat=n={n}:v=0:a=1[out]' -map '[out]' final.wav
    
    点赞 评论 复制链接分享