How do I resolve ffmpeg concat command error "unknown keyword..."?
Solution 1
Docs for several ways of concatenating files: https://trac.ffmpeg.org/wiki/Concatenate
Here's a command I use to concatenate videos:
ffmpeg \
-i "concat:input1.avi|input2.avi|input3.avi" \
-c:a copy \
-c:v copy \
output.avi
Solution 2
This is a bit late for the original post, but I was just searching for answers to the same problem so I think it's still relevant and I haven't found any more recent posts answering the same problem.
I found that my .txt file was encoded wrong. I opened the file in Notepad and did a 'Save As...' I changed the encoding to UTF-8 and the ffmpeg concat command worked.
Solution 3
Your text file is likely encoded in UTF-16.
Fix: (Windows 10)
- Open text file
- Select 'Save as'
- Look by the save button, you get to pick encoding with a drop down box, select UTF-8.
- Save and run ffmpeg again.
I used the Powershell code on ffmpegs webpage to make a text file with filenames, and Powershell seems to save text files as some variant of UTF-16, so I chose the safer UTF-8.
Solution 4
I tried all of the aforementioned and it didn't work.
It looks like that the file names in the list have to be specially formatted to look like:
file '/path/to/file1.wav'
with a word file included. I spend a lot of time trying to guess why ffmpeg encountered an error trying to read the file names. It didn't matter if they were in the list or in the command line. So only after I utilized a command
for f in *.wav; do echo "file '$f'" >> mylist.txt; done
to make list from ffmpeg's manual I had success. The only difference was an additional word file.
Here you can read it yourself: https://trac.ffmpeg.org/wiki/Concatenate#demuxer
Solution 5
Nobody had a full, working, concat text file batch file anywhere. So I am posting it
md ts
for %%x in (input\*.m4a) do (ffmpeg -i "%%x" -c copy -bsf:v h264_mp4toannexb ts\%%~nx.ts)
for %%c in ("ts\*ts") do (echo file '%%c')>>list.txt
for %%f in (input\*.m4a) do (set fn=%%~nf)
ffmpeg -f concat -safe 0 -i "list.txt" -c copy "%cd%\%fn%".m4a
Scorb
Updated on June 14, 2022Comments
-
Scorb 6 monthsI am trying to concatenate two video files using ffmpeg, and I am receiving an error.
To eliminate compatibility issues between the two videos, I have been concatenating the same video with itself, and the same error persists.
ffmpeg \ -f concat \ -safe 0 \ -i intro_prepped.avi intro_prepped.avi \ -c copy \ concat.aviAnd the error output I receive is....
[concat @ 0x220d420] Line 1: unknown keyword 'RIFFf�?' intro_prepped.avi: Invalid data found when processing input
I have tried various combinations of concat flags and have not been able to get it to work. Has anyone seen this error before?
-
Scorb over 5 yearsIs there a way to concatenate two files on the command line? I am doing it from a bash script and do not know the file names ahead of time. -
L. Scott Johnson over 5 yearsSure. See the other examples in that link. -
Astrokiwi almost 3 yearsI tried: ` ffmpeg -i "concat:media3.mp4|media4.mp4|media5.mp4" -c:a copy -c:v copy output.mp4` And it just produced a copy of media3.mp4, without any concatenation. However, this version from your link worked: ` ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4` worked, wheremylist.txtwas: ` # this is a comment file 'media3.mp4' file 'media4.mp4' file 'media5.mp4'` Any idea what the difference is here? -
Arvindh Mani almost 2 yearsThis was the issue for me too. Thank you. For those using Notepad++, the same can be done there with the 'Encoding' tab on the main title bar. -
Ruslan Mukhanov over 1 yearthe difference is the word file. Look at my answer below
-
gargoylebident over 1 yearClick on current encoding name on right side of status bar or press Ctrl+Shift+P - and type "Change File Encoding" to achieve this in VSCode.