I have several chunks in folder.
0001.mp4
0002.mp4
0003.mp4
...
0112.mp4
I would like to merge them into full.mp4
I tried to use:
avconv -f concat -i <(printf "file '%s'\n" /root/chunk/*.mp4) -y \
-c copy /root/test/full.mp4
Unknown input format: 'concat'
avconv -f concat -i <(printf "%s|" /root/chunk/*.mp4) -y \
-c copy /root/test/full.mp4
Unknown input format: 'concat'
avconv -i concat:`ls -ltr /root/chunk/*.mp4 | awk 'BEGIN {ORS="|"} { print $9 }'` \
-c:v copy -c:a copy /root/test/full.mp4
In last edition only one input file was catched to output.
How to merge all chunks from folder into full video?
I don't want to use ffmpeg or other. Avconv only.
avconv -i concat:file1.mp4\|file2.mp4 -c copy output.mp4
I don't know if works with any container's type ( worked for me with AVI
).
mp4
files cannot be simply concatenated, as the "accepted" answer suggests.
If you run that, and that alone, you'll end up with output.mp4
having only the contents of file1.mp4
.
That said, what you're looking to do in the original question can in fact be done, as long as you split original file into mpeg streams correctly.
The following commands will split input.mp4
into 3x 60 second segments, in file[1-3].ts:
avconv -ss 0 -i input.mp4 -t 60 -vcodec libx264 -acodec aac \
-bsf:v h264_mp4toannexb -f mpegts -strict experimental -y file1.ts
avconv -ss 0 -i input.mp4 -t 60 -vcodec libx264 -acodec aac \
-bsf:v h264_mp4toannexb -f mpegts -strict experimental -y file2.ts
avconv -ss 0 -i input.mp4 -t 60 -vcodec libx264 -acodec aac \
-bsf:v h264_mp4toannexb -f mpegts -strict experimental -y file3.ts
You can then put them back together much as the other answer suggests:
avconv -i concat:"file1.ts|file2.ts|file3.ts" -c copy \
-bsf:a aac_adtstoasc -y full.mp4
I used this process to create a scalable, parallel transcoder as described at:
For mp4 the only working solution I found was with MP4Box from gpac package
#!/bin/bash
filesList=""
for file in $(ls *.mp4|sort -n);do
filesList="$filesList -cat $file"
done
MP4Box $filesList -new merged_files_$(date +%Y%m%d_%H%M%S).mp4
or command is
MP4Box -cat file1.mp4 -cat file2.mp4 -new mergedFile.mp4
with mencoder and avconv I could'nt make it work :-(
this works
avconv -i 1.mp4 1.mpeg
avconv -i 2.mp4 2.mpeg
avconv -i 3.mp4 3.mpeg
cat 1.mpeg 2.mpeg 3.mpeg | avconv -f mpeg -i - -vcodec mpeg4 -strict experimental output.mp4
Above works if you only have avconv - however ffmpeg has added functions ... to quote :
"Above avconv steps does unnecessary additional lossy encoding steps which is slow and reduces the quality of the output. I would recommend using the concat demuxer (additional info) or concat filter instead, but avconv lacks those features available in ffmpeg from FFmpeg" – @LordNeckbeard
SEE https://trac.ffmpeg.org/wiki/Concatenate
If you're using a system that supports named pipes, you can use those to avoid creating intermediate files - this sends stderr (which ffmpeg sends all the written data to) to /dev/null, to avoid cluttering up the command-line:
mkfifo temp1 temp2
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp1 2> /dev/null
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp2 2> /dev/null
ffmpeg -f mpegts -i "concat:temp1|temp2" -c copy -bsf:a aac_adtstoasc output.mp4
This one works for me:
avconv -i "concat:001.mp4|002.mp4|003.mp4" -c copy full.mp4
Just concats all the files into one mp4 without re-encoding them.
This method will do for concating raw *.avi files only, I suppose. But since lots of people willing to join avi files will end up viewing this question I'll post my answer here anyway:
cat *.avi > out_tmp.avi
avconv -i out_tmp.avi -c copy output.avi
One more time: works for uncompressed *.avi files only.
I did that with avidemux (gtk tool). It is available as a package under most linuxes, also for Windows and Mac. I simply opened the first file. Then I added the next ones in order. Finally, I saved the concatenated video using audio and video copy and format mp4.
It worked great !
I am using ffmpeg
command to do this. Here is example:
ffmpeg -i concat:/dev/null|file1.ts|file2.ts -c copy -bsf:a aac_adtstoasc -y output.mp4
Take a look at this github project for Distributed parallel video trascoding
I found a tool named Avdshare Video Converter 7 that successfully concatenates my videos. It even transcodes them to just about any format I want.
I tried every solution on this page... all of them gave me the same errors you likely encountered if you're reading my answer. Does "Protocol not found" get you upset? Them maybe this is the program for you too.
I'm running it on windows.
The steps to concatenate two videos in the program are:
Drag and drop your videos onto the program
Click Merge
Choose a "save profile" that specifies every parameter you could ever want to tweak
Click Save Button
After no getting an answer to the error message I was having with all of these similar answers:
~ avconv -i 'concat:' -c copy test.mp4
avconv version 12.3, Copyright (c) 2000-2018 the Libav developers
built on Jan 22 2019 21:47:11 with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
concat:: Protocol not found
I dug through some Google results, went into the bug tracker, and found these:
- https://lists.libav.org/pipermail/libav-bugs/2017-October/005736.html
- https://bugzilla.libav.org/show_bug.cgi?id=1026#c4
- https://bugzilla.libav.org/show_bug.cgi?id=1083
- https://bugzilla.libav.org/buglist.cgi?bug_status=all&content=concat&no_redirect=1&order=Importance&product=&query_format=specific
Seems it was not only disabled at some point, but removed in version 12, but my build 12.3 on Mac 10.13.6 from Homebrew still has "concat" listed in the input protocols, and I see it in the documentation as well, thus that 1 outstanding bug report.
I've had some luck using this command:
cat *.VOB | avconv -i - -c copy test.mp4
来源:https://stackoverflow.com/questions/18552901/how-to-merge-videos-by-avconv