Example #1
0
    def __init__(self, input_file, output_dir):
        # Process the configuration file
        config_file_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), 'scripts.conf')

        # Call the super constructor
        super(QualityTester, self).__init__(config_file_path)

        # Handle our input and output files
        self.input_path = os.path.abspath(input_file)
        self.input_basename = os.path.splitext(
            os.path.basename(self.input_path))[0]
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)
        elif not os.path.isdir(output_dir):
            raise Exception("Output path is not a directory")
        self.output_dir = output_dir

        # Create result type
        self.ResultType = collections.namedtuple(
            'QualTestResult', ['name', 'encode_time', 'bitrate', 'file_size'])

        # Create transcoder
        self.transcoder = Transcoder.Transcoder(config_file_path)

        return
Example #2
0
def process_file(path, transcode, rename_ext):

    # Process the configuration file
    config_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'scripts.conf')

    path = os.path.abspath(path)

    # Create Comskip Object
    comskip = Comskip.Comskip(config_file_path)

    # Get the segments that are commerical free
    intermediate_path, segments = comskip.GenerateSegments(path)

    # Cut the commercials out of the original file
    processed_file = comskip.ProcessSegments(intermediate_path, segments)

    if transcode:
        # Transcode into a better format
        t = Transcoder.Transcoder(config_file_path)
        # CRF and preset are thrown away when using auto
        processed_file = t.Transcode(processed_file, 'auto', '23', 'medium')

    # Use the processed file extension or not?
    if rename_ext:
        path = os.path.splitext(path)[0] + os.path.splitext(procesed_file)[1]

    # Check that file looks sane and then copy it over
    return comskip.SafeOverwrite(path, processed_file, .1, 1.2)