Search code examples
linuxbashshellaudiowav

How to concatenate a list of wav files?


I have a list of wav files in file.txt

1.wav
2.wav
...

I used the below command to perform the action.

ffmpeg -f concat -safe 0 -i file.txt -c copy output.wav

However I get

[concat @ 0x5574a8046900] Line 1: unknown keyword 1.wav: Invalid data found when processing input

Why does this not work?


Solution

  • Based on this wiki page, you need to modify your file.txt as follows:

    file '1.wav'
    file '2.wav'
    # ... etc
    

    The command itself, should work fine.

    Excerpts from the page:

    ... This demuxer reads a list of files and other directives from a text file and demuxes them one after the other, as if all their packets had been muxed together. ...

    Instructions

    Create a file mylist.txt with all the files you want to have concatenated in the following form (lines starting with a # are ignored):

    # this is a comment
    file '/path/to/file1.wav'
    file '/path/to/file2.wav'
    file '/path/to/file3.wav'