How to concatenate two MP4 files using FFmpeg?

后端 未结 22 3055
遇见更好的自我
遇见更好的自我 2020-11-22 02:32

I\'m trying to concatenate two mp4 files using ffmpeg. I need this to be an automatic process hence why I chose ffmpeg. I\'m converting the two files into .ts files and th

22条回答
  •  盖世英雄少女心
    2020-11-22 03:21

    Merging all mp4 files from current directory

    I personnaly like not creating external file that I have to delete afterwards, so my solution was following which includes files numbering listing (like file_1_name, file_2_name, file_10_name, file_20_name, file_100_name, ...)

    #!/bin/bash
    filesList=""
    for file in $(ls -1v *.mp4);do #lists even numbered file
        filesList="${filesList}${file}|"
    done
    filesList=${filesList%?} # removes trailing pipe
    ffmpeg -i "concat:$filesList" -c copy $(date +%Y%m%d_%H%M%S)_merged.mp4
    

提交回复
热议问题