Use ffmpeg copy codec to combine *.ts files into a single mp4
Solution 1:
I'm not sure why ffmpeg is giving you an error. However ts is one of the few formats that can simply be concatenated. Then, once you have a single ts, transmux to mp4.
Under windows:
copy /b segment1_0_av.ts+segment2_0_av.ts+segment3_0_av.ts all.ts
ffmpeg -i all.ts -acodec copy -vcodec copy all.mp4
Under GNU/Linux, using bash:
cat segment1_0_av.ts segment2_0_av.ts segment3_0_av.ts > all.ts
ffmpeg -i all.ts -acodec copy -vcodec copy all.mp4
Solution 2:
Using copy or cat to combine the files like szatmary's current top answer might leave you with a file that plays far past the limit and can't seek along with playback issues.
Instead, to combine these files properly use ffmpeg as instructed in https://trac.ffmpeg.org/wiki/Concatenate. (Install ffmpeg here if you don't already have it https://github.com/adaptlearning/adapt_authoring/wiki/Installing-FFmpeg.)
If you're too lazy to read my first link, you basically have to create a .txt file listing all the files you want to combine like so (which my first link gives instructions on how to do easily) in the folder where you're doing the concatenation:
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
Here's a copy paste from my first link on one way to create a text file if you have Windows on commandline for instance but obviously you can make the file manually or however you want:
(for %i in (*.ts) do @echo file '%i') > mylist.txt
Double check that your .txt file looks good and is formatted correctly!
After this, on commandline run:
ffmpeg -f concat -i mylist.txt -c copy all.ts
where 'mylist.txt' is the .txt file you just made.
Check if the resultant file plays video correctly. From here, you can transmux to mp4 as usual if you like:
ffmpeg -i all.ts -acodec copy -vcodec copy all.mp4
Solution 3:
Putting all together
Using the Juan Aquino's answer (and correcting the first command to be compatible with Bash and using the natural ordering of files), plus the 7vujy0f0hy's answer, a simple working script for a Linux Bash shell is:
#!/bin/bash
for i in `ls *.ts | sort -V`; do echo "file $i"; done >> mylist.txt
ffmpeg -f concat -i mylist.txt -c copy -bsf:a aac_adtstoasc video.mp4
Solution 4:
The correct way to concat multiple video files from m3u8 playlist is
ffmpeg -i "index.m3u8" -codec copy output.mp4
- the m3u8 playlist can be on web or locally in directory
- it contains list of file paths relative to the playlist
-
-codec copy
to avoid encoding - container type matters:
-
*.mp4
is fine but it seems little slow to mux when playlist is fetched from web -
*.mkv
or*.ts
worked best for me
-