2019年11月30日星期六

How to merge videos in batch?

What if we have hundreds of videos and want to merge them into one video in batches without too much trouble?


This can be done in two steps:
1. Create a text file videolist.txt
The contents are as follows:


  1. file filename1
  2. file filename2
  3. file filename3
  4. ... ...
  5. file filnamen
  6. e.g.

  1. file '1.mp4'
  2. file '2.mp4'
  3. file '3.mp4'
  4. file '4.mp4'
  5. file '5.mp4'
  6. ... ...
  7. file '3000.mp4'
We can implement it using simple programming(Python):

  1. f = open('test.txt','a')
  2. for im in range(151):
  3. content = str(im)+'.mp4'
  4. f.write('file'+'\x20'+'\''+content+'\''+'\n')
  5. f.close
2. Enter the following command from the command prompt:

ffmpeg -f concat -i filelist.txt -c copy output.mp4

Of course, the premise is to install ffmpeg and add it to the environment path, which is relatively easy, and there are many related tutorials.
Our task of merging videos can be finished as shown below:

没有评论:

发表评论