Reputation: 1860
I 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.avi
And 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?
Upvotes: 17
Views: 38407
Reputation: 169
for me it worked by disabling BOM on the UTF-8 format. So the file was UTF-8 and noBOM.
e.g. the contents of the text file:
file 'video1.mp4'
file 'video2.mp4'
file 'video3.mp4'
and use:
ffmpeg -f concat -i input_videos.txt -c copy ffmpeg_out.mp4
Upvotes: 1
Reputation: 1
Latest:
Using windows 10
gather files using this with sort according to date modification:
foreach ($i in Get-ChildItem -Path .\*.mp4 | Sort-Object -Property LastWriteTime) {echo "file '$i'" >> mylist.txt}
save as the mylist as UTF-8
combine them by running this at powershell:
ffmpeg -f concat -safe 0 -i mylist.txt -vcodec copy output.mp4
ffmpeg must be installed to use directly.
if you want to just directly use ffmpeg exe without installation then use:
./ffmpeg -f concat -safe 0 -i mylist.txt -vcodec copy output.mp4
given that ffmpeg.exe is in the same directory and powershell is at that directrory
Upvotes: 0
Reputation: 59
I struggled with all these instructions above on my Mac (M1, Ventura, ffmpeg version N-109530-g4a80db5fc2-tessus). None of them worked for me - but a combination of all did the trick!
This is how I got it running:
input.txt
in this folder - content looks like this:
file 'input1.mp4'
file 'input2.mp4'
file 'input3.mp4'
file 'input4.mp4'
UTF-8
file
keyword must be present'/path/to/input1.mp4'
)'
ffmpeg -f concat -i input.txt -c copy ffmpegOUT.mp4
Upvotes: 4
Reputation: 402
Your text file is likely encoded in UTF-16.
Fix: (Windows 10)
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.
Upvotes: 6
Reputation: 433
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
Upvotes: 11
Reputation: 281
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
Upvotes: 14
Reputation: 680
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
Upvotes: 1
Reputation: 221
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.
Upvotes: 22
Reputation: 4382
The input file should be a text file, not an avi. The text file lists the files to concatenate.
See the concat demuxer documentation and FFmpeg Wiki: Concat.
Upvotes: 1