def clean_job_for_quality(batch_job_dict, fallback=True): """ Removes jobs from the batch description that are not suitable for the master video's quality. It applies only for encoding jobs! @param batch_job_dict: the dict containing the batch description @type batch_job_dict: dict @param @return: the cleaned dict @rtype: dict """ survived_jobs = [] fallback_jobs = [] other_jobs = [] for job in batch_job_dict["jobs"]: if job["mode"] == "encode": if getval(job, "fallback") and fallback: fallback_jobs.append(job) if getval(job, "enforce"): survived_jobs.append(job) else: profile = None if getval(job, "profile"): profile = get_encoding_profile(job["profile"]) if assure_quality( input_file=batch_job_dict["input"], aspect=chose2("aspect", job, profile), target_width=chose2("width", job, profile), target_height=chose2("height", job, profile), target_bitrate=chose2("videobitrate", job, profile), ): survived_jobs.append(job) else: other_jobs.append(job) if survived_jobs: survived_jobs.extend(other_jobs) new_jobs = survived_jobs else: fallback_jobs.extend(other_jobs) new_jobs = fallback_jobs pprint(locals()) batch_job_dict["jobs"] = new_jobs return batch_job_dict
def clean_job_for_quality(batch_job_dict, fallback=True): """ Removes jobs from the batch description that are not suitable for the master video's quality. It applies only for encoding jobs! @param batch_job_dict: the dict containing the batch description @type batch_job_dict: dict @param @return: the cleaned dict @rtype: dict """ survived_jobs = [] fallback_jobs = [] other_jobs = [] for job in batch_job_dict['jobs']: if job['mode'] == 'encode': if getval(job, 'fallback') and fallback: fallback_jobs.append(job) if getval(job, 'enforce'): survived_jobs.append(job) else: profile = None if getval(job, 'profile'): profile = get_encoding_profile(job['profile']) if assure_quality(input_file=batch_job_dict['input'], aspect=chose2('aspect', job, profile), target_width=chose2('width', job, profile), target_height=chose2('height', job, profile), target_bitrate=chose2( 'videobitrate', job, profile)): survived_jobs.append(job) else: other_jobs.append(job) if survived_jobs: survived_jobs.extend(other_jobs) new_jobs = survived_jobs else: fallback_jobs.extend(other_jobs) new_jobs = fallback_jobs pprint(locals()) batch_job_dict['jobs'] = new_jobs return batch_job_dict
def clean_job_for_quality(batch_job_dict, fallback=True): """ Removes jobs from the batch description that are not suitable for the master video's quality. It applies only for encoding jobs! @param batch_job_dict: the dict containing the batch description @type batch_job_dict: dict @param @return: the cleaned dict @rtype: dict """ survived_jobs = [] fallback_jobs = [] other_jobs = [] for job in batch_job_dict['jobs']: if job['mode'] == 'encode': if getval(job, 'fallback') and fallback: fallback_jobs.append(job) if getval(job, 'enforce'): survived_jobs.append(job) else: profile = None if getval(job, 'profile'): profile = get_encoding_profile(job['profile']) if assure_quality(input_file=batch_job_dict['input'], aspect=chose2('aspect', job, profile), target_width=chose2('width', job, profile), target_height=chose2('height', job, profile), target_bitrate=chose2('videobitrate', job, profile)): survived_jobs.append(job) else: other_jobs.append(job) if survived_jobs: survived_jobs.extend(other_jobs) new_jobs = survived_jobs else: fallback_jobs.extend(other_jobs) new_jobs = fallback_jobs pprint(locals()) batch_job_dict['jobs'] = new_jobs return batch_job_dict
def test_assure_quality(self): """ Test if the quality is detected correctly""" self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 1920, 1080, 6000000, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 1280, 720, 6000000, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 4443, 2500, 6000000, True, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 1280, 720, 10000000, True, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 1920, 1080, 10000000, True, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 1920, 1080, 6000000, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, None, 720, 6000000, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, None, 2500, 6000000, True, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, None, 720, 10000000, True, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, None, 1080, 10000000, True, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 1920, None, None, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 1280, None, None, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 4443, None, None, True, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, None, None, 10000000, True, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, None, None, 6000000, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 800, 600, 6000000, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, "4:3", 800, 600, 6000000, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, "4:3", 1440, 1080, 6000000, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, 1.333333333333333333, 800, 600, 6000000, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, 1.333333333333333333, 1440, 1080, 6000000, True, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, 1.333, 800, 600, 6000000, True, 0.95), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, 1.333, 1440, 1080, 6000000, True, 0.95), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 800, 600, 6000000, True, 0.95), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, None, 1440, 1080, 6000000, True, 0.95), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, 1.333, 800, 600, 6000000, False, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(video01_out03, 1.333, 1440, 1080, 6000000, False, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(movie_no_aspect, None, 800, 600, 6000000, False, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(movie_no_aspect, None, 1440, 1080, 6000000, False, 1.0), True) self.assertEqual(bibencode_encode.assure_quality(movie_no_aspect, None, 1920, 1080, 6000000, False, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(movie_no_aspect, None, 1920, 1080, 6000000, True, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(movie_no_aspect, "16:9", 1920, 1080, 6000000, False, 1.0), False) self.assertEqual(bibencode_encode.assure_quality(movie_no_aspect, "16:9", 1920, 1080, 6000000, True, 1.0), True)
def test_assure_quality(self): """ Test if the quality is detected correctly""" self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 1920, 1080, 6000000, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 1280, 720, 6000000, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 4443, 2500, 6000000, True, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 1280, 720, 10000000, True, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 1920, 1080, 10000000, True, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 1920, 1080, 6000000, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, None, 720, 6000000, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, None, 2500, 6000000, True, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, None, 720, 10000000, True, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, None, 1080, 10000000, True, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 1920, None, None, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 1280, None, None, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 4443, None, None, True, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, None, None, 10000000, True, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, None, None, 6000000, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 800, 600, 6000000, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, "4:3", 800, 600, 6000000, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, "4:3", 1440, 1080, 6000000, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, 1.333333333333333333, 800, 600, 6000000, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, 1.333333333333333333, 1440, 1080, 6000000, True, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, 1.333, 800, 600, 6000000, True, 0.95), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, 1.333, 1440, 1080, 6000000, True, 0.95), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 800, 600, 6000000, True, 0.95), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, None, 1440, 1080, 6000000, True, 0.95), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, 1.333, 800, 600, 6000000, False, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(video01_out03, 1.333, 1440, 1080, 6000000, False, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(movie_no_aspect, None, 800, 600, 6000000, False, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(movie_no_aspect, None, 1440, 1080, 6000000, False, 1.0), True) self.assertEqual( bibencode_encode.assure_quality(movie_no_aspect, None, 1920, 1080, 6000000, False, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(movie_no_aspect, None, 1920, 1080, 6000000, True, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(movie_no_aspect, "16:9", 1920, 1080, 6000000, False, 1.0), False) self.assertEqual( bibencode_encode.assure_quality(movie_no_aspect, "16:9", 1920, 1080, 6000000, True, 1.0), True)