Ejemplo n.º 1
0
    def split(self, max_num, min_time=0, frames=True, time_to_frames=False, threads=None, runner=proc.run_many):
        output = None if not self.out else self.out.format("{0}", "{1}")

        probe = self.probe()
        vprobe = probe.streams[0]

        if frames:
            fps = vprobe.r_frame_rate
            if "/" in fps:
                a, b = fps.split("/")
                fps = int(a) / int(b)
            else:
                fps = float(fps)
            try:
                duration = int(vprobe.nb_frames)
            except Exception:
                time_duration = float(probe.format.duration)
                duration = int(round(time_duration * fps))
        else:
            fps = None
            try:
                duration = float(vprobe.duration)
            except Exception:
                duration = float(probe.format.duration)
            duration = int(math.ceil(duration))

        base_cmds = command.split(duration, max_num, min_time, fps, time_to_frames)
        no_container = command.no_container()

        cmds = []
        all_names = []
        for part, base in enumerate(base_cmds):
            base["other"] += no_container
            cmd, names = command.convert(
                self.filename, self.flavors, base, ext="h264", part=part, threads=threads, output=output, audio=False
            )
            cmds.append(cmd)
            all_names.append(names)

        if runner:
            runner(cmds)

        self.parts = zip(*all_names)
        return cmds
Ejemplo n.º 2
0
 def conv_original(self, convert=True):
     output = None if not self.out else self.out.format("{0}", "{1}")
     cmd = command.convert(self.filename, {}, output=output, audio=False)
     if convert:
         proc.run_local(cmd)
     return self.as_t(cmd[-1])