Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge videos by avconv?

Tags:

video

avconv

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.

like image 515
Alex Avatar asked Aug 31 '13 21:08

Alex


People also ask

What is video concatenation?

When using FFmpeg to merge a series of video clips, the process is called concatenation, or concat for short. There are several ways that videos can be concatenated, depending on whether the individual videos share the same codec or not.


2 Answers

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:

  • http://blog.dustinkirkland.com/2014/07/scalable-parallel-video-transcoding-on.html
like image 160
Dustin Kirkland Avatar answered Sep 21 '22 01:09

Dustin Kirkland


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 ).

like image 27
test Avatar answered Sep 20 '22 01:09

test