Last active
August 6, 2022 20:15
-
-
Save itsdogtime/9eb9befd61c17135840d32ea3d3d92cc to your computer and use it in GitHub Desktop.
automatically record and archive CPMA demos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import os | |
import re | |
import glob | |
import shutil | |
import datetime | |
user = "" | |
base_dir = "" | |
cpm_dir = base_dir + "" | |
demo_dir = cpm_dir + "" | |
archive_dir = "" | |
os.chdir(demo_dir) | |
#move demos that arent mine | |
my_demos = glob.glob("*" + user + "(POV)" + "*.dm_68") | |
all_demos = sorted(glob.glob("*.dm_68"), key=os.path.getmtime) | |
total_demos = len( all_demos ) | |
for i, filename in enumerate(all_demos): | |
os.chdir(base_dir) | |
# trim ".dm_68" from filename | |
demo_name = all_demos[ i ][:len(all_demos[ i ])-6] | |
game = subprocess.Popen( | |
'quake3e.x64.exe ' + | |
'+set fs_game "cpma" ' + | |
'+set r_customwidth "1920" ' + | |
'+set r_customheight "1080" ' + | |
'+set r_mode "" ' + | |
'+set r_fullscreen 0 ' + | |
'+set r_picmip "16" ' + | |
'+set nextdemo quit ' + # quit after this demo so we can continue the loop from code | |
'+demo "' + demo_name + '" ' + | |
'+set cl_aviFrameRate 60 ' + | |
'+set cl_avipipeformat "-preset slow -c:v libx264 -pix_fmt yuv420p -bf 2 -codec:a aac -b:a 160k -r:a 30050 -movflags faststart" ' + | |
'+video-pipe "' + demo_name + '"' | |
) | |
game.wait() | |
if archive_dir: | |
if os.path.exists( archive_dir ): | |
os.chdir(demo_dir) | |
shutil.move(filename, archive_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment