How to merge videos by avconv?

前端 未结 10 2217
逝去的感伤
逝去的感伤 2021-01-30 17:12

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:

10条回答
  •  旧巷少年郎
    2021-01-30 17:41

    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
    

提交回复
热议问题