- ffmpeg를 https://ffmpeg.org/download.html 에서 받아서 압축을 푼 후, PATH 환경 변수에 해당 경로를 추가해서 커맨드 프롬프트에서 실행 가능하도록 만든다.
-
여러 동영상 파일명을 적은 Text file을 하나 만든다.
[code]
file ‘StepByStep/01_1-3/1-3-2.m4v’
file ‘StepByStep/01_1-3/1-3-3.m4v’
file ‘StepByStep/01_1-3/1-3-4.m4v’
file ‘StepByStep/01_1-3/1-3-5.m4v’
file ‘StepByStep/01_1-3/1-3-6.m4v’
file ‘StepByStep/01_1-3/1-3-7.m4v’
file ‘StepByStep/01_1-3/1-3-8.m4v’
file ‘StepByStep/01_1-3/1-3-9.m4v’
file ‘StepByStep/01_1-3/1-3-10.m4v’
file ‘StepByStep/01_1-3/1-3-11.m4v’
file ‘StepByStep/01_1-3/1-3-12.m4v’
file ‘StepByStep/01_1-3/1-3-13.m4v’
file ‘StepByStep/01_1-3/1-3-14.m4v’
file ‘StepByStep/01_1-3/1-3-15.m4v’
file ‘StepByStep/01_1-3/1-3-16.m4v’
file ‘StepByStep/01_1-3/1-3-17.m4v’
file ‘StepByStep/01_1-3/1-3-18.m4v’
file ‘StepByStep/01_1-3/1-3-19.m4v’
file ‘StepByStep/01_1-3/1-3-20.m4v’
file ‘StepByStep/01_1-3/1-3-21.m4v’
file ‘StepByStep/01_1-3/1-3-22.m4v’
file ‘StepByStep/01_1-3/1-3-23.m4v’
file ‘StepByStep/01_1-3/1-3-24.m4v’
file ‘StepByStep/01_1-3/1-3-25.m4v’
file ‘StepByStep/01_1-3/1-3-26.m4v’
file ‘StepByStep/01_1-3/1-3-27.m4v’
file ‘StepByStep/01_1-3/1-3-28.m4v’
file ‘StepByStep/01_1-3/1-3-29.m4v’
file ‘StepByStep/01_1-3/1-3-30.m4v’
file ‘StepByStep/01_1-3/1-3-31.m4v’
file ‘StepByStep/01_1-3/1-3-32.m4v’
file ‘StepByStep/01_1-3/1-3-33.m4v’
file ‘StepByStep/01_1-3/1-3-34.m4v’
file ‘StepByStep/01_1-3/1-3-35.m4v’
file ‘StepByStep/01_1-3/1-3-36.m4v’
[/code]
만드는데 쓴 bash shell 명령은 다음과 같다.
[code]
for DIR in `ls`; do pushd $DIR; for FILE in `ls -tr`; do echo "file ‘StepByStep/`basename \`pwd\“/$FILE’"; done > ../../`basename \`pwd\`.txt`; popd; done
[/code]
3. 다음 명령어를 커맨드 프롬프트에서 실행한다.
[code]
ffmpeg -f concat -i filename.txt -c copy -fflags +genpts output.mp4
[/code]
이걸 디렉토리 별로 돌린 bash shell 명령은 다음과 같다
[code]
for TXT in `ls *.txt`; do ffmpeg -f concat -i $TXT -c copy -fflags +genpts `echo $TXT | cut -d. -f1`.mp4; done;
[/code]
참고: https://superuser.com/questions/1039678/merge-multiple-video-with-ffmpeg-single-command-line-in-specific-time-without-cu