Compare commits

...

2 Commits

Author SHA1 Message Date
6752425682 Add script to encode all videos in "source" subfolder
Some checks failed
ci/woodpecker/push/linting Pipeline failed
2022-11-10 14:46:16 +01:00
2bb1b1d778 Remove accidental argument. Change helptext wording 2022-11-10 14:45:49 +01:00
2 changed files with 47 additions and 20 deletions

View File

@ -4,15 +4,51 @@ import encode_single_video
import os
# tuple of video file extensions
videofileextensions = (".webm", ".mp4")
import argparse
videofiles: list[str] = []
for root, dirs, files in os.walk("source"):
for file in files:
if file.endswith(videofileextensions):
filepath = os.path.join(root, file)
videofiles.append(filepath)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="")
for video in videofiles:
encode_single_video.main(inputfile=video)
parser.add_argument(
"-o",
"--output-dir",
required=False,
type=str,
help='Output directory for encodes. Default is "encodes" in current working directory',
default="encodes",
)
parser.add_argument(
"-k",
"--keep-encodes",
action="store_true",
required=False,
help="Don't delete encodes after getting their scores. Default is False (delete)",
)
args = parser.parse_args()
# REVIEW expose this as variable/argument?
outputpath: str = args.output_dir
keepencodes: bool = args.keep_encodes
# tuple of video file extensions
videofileextensions = (".webm", ".mp4")
# search all video files in "source"
videofiles: list[str] = []
for root, dirs, files in os.walk("source"):
for file in files:
if file.endswith(videofileextensions):
filepath = os.path.join(root, file)
videofiles.append(filepath)
try:
# encode all video files
for video in videofiles:
encode_single_video.main(
inputfile=video, outputpath=outputpath, keepencodes=keepencodes
)
except KeyboardInterrupt:
encode_single_video.cleanup(keepencodes=keepencodes)

View File

@ -417,21 +417,12 @@ if __name__ == "__main__":
help="Input file to encode",
)
# in case you wanted to rerun the conversion for everything
parser.add_argument(
"-r",
"--reset",
required=False,
action="store_true",
help="Rerun conversion for all files",
)
parser.add_argument(
"-k",
"--keep-encodes",
action="store_true",
required=False,
help="Don't delete encodes after getting their scores. Default is delete (False)",
help="Don't delete encodes after getting their scores. Default is False (delete)",
)
args = parser.parse_args()