ffmpeg: Combine/merge multiple mp4 videos not working, output only contains the first video

前端 未结 10 882
逝去的感伤
逝去的感伤 2020-12-22 22:48

Here is the command I am using to combine multiple videos:

ffmpeg -i 75_540_38HQ2.mp4 -i 76_70_20.mp4 -i 76_173_80.mp4 -i 81_186_35.mp4 -vcodec copy -acodec copy M         


        
10条回答
  •  不思量自难忘°
    2020-12-22 23:26

    You have to convert them into an MPEG format that can be easily concatenated. Below is a script I use and call "ffcat" for my GoPro videos. It essentially runs several "ffmpeg -i" commands which produce concatenate-able MPEG, which is piped to an ffmpeg command that then converts them to an H.264 mp4 file.

    It also sizes the videos to 720p but you may not want that.

    The "h264options" are flags I recently found on the internet at h264.code-shop.com

    Hope this helps, Reid


    cmd="( "
    
    h264options="-vcodec libx264 -b 512k -flags +loop+mv4 -cmp 256 \
     -partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 \
     -me_method hex -subq 7 -trellis 1 -refs 5 -bf 3 \
     -flags2 +bpyramid+wpred+mixed_refs+dct8x8 -coder 1 -me_range 16 \
       -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10\
     -qmax 51 -qdiff 4"
    
    outfile="out-`date +%F-%H%M.%S`.mp4"
    
    for i; do
        cmd="${cmd}ffmpeg -i $i -ab 256000 -vb 10000000 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -f mpeg -; "
    done
    cmd="${cmd} ) | ffmpeg -y -i - -threads 8 ${h264options} -vb 10000000 -acodec libfaac -ar 44100 -ab 128k -s 1280x720 ${outfile}"
    echo "${cmd}"
    eval ${cmd}
    

提交回复
热议问题