Add autocat.py.
This commit is contained in:
parent
725a91f1cc
commit
3e5e421484
1 changed files with 24 additions and 0 deletions
24
autocat.py
Normal file
24
autocat.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
|
||||||
|
if len(sys.argv) < 3:
|
||||||
|
raise ValueError()
|
||||||
|
|
||||||
|
output_filename = sys.argv.pop(-1)
|
||||||
|
patterns = sys.argv[1:]
|
||||||
|
|
||||||
|
names = [name for pattern in patterns for name in glob.glob(pattern)]
|
||||||
|
names = [os.path.abspath(x) for x in names]
|
||||||
|
cat_lines = [f'file \'{x}\'' for x in names]
|
||||||
|
cat_text = '\n'.join(cat_lines)
|
||||||
|
cat_file = tempfile.TemporaryFile('w', encoding='utf-8', delete=False)
|
||||||
|
cat_file.write(cat_text)
|
||||||
|
cat_file.close()
|
||||||
|
|
||||||
|
cmd = f'ffmpeg -f concat -safe 0 -i {cat_file.name} -c copy "{output_filename}"'
|
||||||
|
os.system(cmd)
|
||||||
|
|
||||||
|
os.remove(cat_file.name)
|
Loading…
Reference in a new issue