How to merge videos by avconv?

前端 未结 10 2197
逝去的感伤
逝去的感伤 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:40

    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 !

    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2021-01-30 17:44

    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 :-(

    0 讨论(0)
  • 2021-01-30 17:44

    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

    0 讨论(0)
提交回复
热议问题