Skip to content
Snippets Groups Projects
Select Git revision
  • 7503a408f4c4214080ccb679d085b4412e72ebc7
  • master default protected
  • th/caddy-wip
  • th/caddy
  • th/lego
  • th/acmebot
  • pyzabbix
  • th/keycloak
8 results

service-after.conf

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    cut_and_transcode.py 2.07 KiB
    
    from job_database_api import JobData
    from jobs.wrapped_job import ContainerConfig, WrappedJob
    import os
    
    
    class CutAndTranscode(WrappedJob):
    
        def __init__(self, jobData: JobData):
            super().__init__(jobData)
            self.input_file = jobData.job_args["input_file"]
            self.in_dir = os.path.dirname(self.input_file)
    
        def make_project_toml(self):
            return f"""
            [lecture]
            course = "{self.jobData.job_args['course']}"
            label = "{self.jobData.job_args['label']}"
            docent = "{self.jobData.job_args['docent']}"
            date = "{self.jobData.job_args['date']}"
            lang = "{self.jobData.job_args.get("lang", "de")}"
    
            [source]
            files = ["{self.input_file}"]
            stereo = false
            start = "{self.jobData.job_args['start_time']}"
            end = "{self.jobData.job_args['end_time']}"
            transcode_lowest = "720p"
            transcode_highest = "1440p"
            fast = []
            questions = []
    
            [progress]
            preprocessed = false
            asked_start_end = true
            asked_fast = true
            asked_questions = true
            rendered_assets = false
            rendered = false
            transcoded = ["720p", "1080p", "1440p"]
            """
    
        def config(self) -> ContainerConfig:
            cfg = ContainerConfig(image="registry.git.fsmpi.rwth-aachen.de/videoag_infra/production/dominic_render_video:latest", args=["-C", self.in_dir])
            cfg.mount_video_fs("/mnt/video_data")
            cfg.resources("8", "12Gi")
            return cfg
    
        def prepare(self, cstate: "ControllerState"):
            # prepare preset
            if not os.path.exists(self.input_file):
                raise Exception(f"Input file {self.input_file} does not exist")
    
            project_toml = os.path.join(self.in_dir, "project.toml")
    
            if os.path.exists(project_toml):
                os.remove(project_toml)  # TODO: handle previous job failure?
    
            with open(project_toml, "w") as f:
                f.write(self.make_project_toml())
    
        def success(self, cstate):
            print("Transcode success!")
    
        def failure(self, cstate):
            print("Transcode fail :(")