diff --git a/src/ffx/ffx_controller.py b/src/ffx/ffx_controller.py index ea70090..9667220 100644 --- a/src/ffx/ffx_controller.py +++ b/src/ffx/ffx_controller.py @@ -501,12 +501,7 @@ class FfxController(): commandSequence1 = (commandTokens + self.__targetMediaDescriptor.getInputMappingTokens(only_video=True)) - # Optional tokens - #NOTE: Filters and so needs to run on the first pass as well, as here - # the required bitrate for the second run is determined and recorded - # TODO: Results seems to be slightly better with first pass omitted, - # Confirm or find better filter settings for 2-pass - # commandSequence1 += self.__context['denoiser'].generatefilterTokens() + commandSequence1 += filterTokens for td in self.__targetMediaDescriptor.getTrackDescriptors(trackType=TrackType.VIDEO): #HINT: Attached thumbnails are not supported by .webm container format diff --git a/tests/unit/test_ffx_controller.py b/tests/unit/test_ffx_controller.py index 0af5db1..7ea80c6 100644 --- a/tests/unit/test_ffx_controller.py +++ b/tests/unit/test_ffx_controller.py @@ -161,6 +161,55 @@ class FfxControllerTests(unittest.TestCase): any(token.startswith("ENCODING_PRESET=") for token in commands[1]) ) + def test_vp9_run_job_applies_identical_video_filters_to_both_passes(self): + context = self.make_context(VideoEncoder.VP9) + target_descriptor, source_descriptor = self.make_media_descriptors() + controller = FfxController(context, target_descriptor, source_descriptor) + commands = [] + + with ( + patch.object( + controller, + "executeCommandSequence", + side_effect=lambda command: commands.append(command) or ("", "", 0), + ), + patch("ffx.ffx_controller.os.path.exists", return_value=False), + ): + controller.runJob( + "input.mkv", + "output.webm", + targetFormat="webm", + chainIteration=[ + { + "identifier": "quality", + "parameters": {"quality": 27}, + }, + { + "identifier": "nlmeans", + "parameters": {}, + "tokens": ["nlmeans=s=2.8"], + }, + { + "identifier": "bwdif", + "parameters": {}, + "tokens": ["bwdif=mode=1"], + }, + ], + cropArguments={ + "output_width": 704, + "output_height": 576, + "x_offset": 8, + "y_offset": 0, + }, + ) + + self.assertEqual(2, len(commands)) + expectedFilterChain = ( + "crop=704:576:8:0, nlmeans=s=2.8, bwdif=mode=1" + ) + self.assert_token_pair(commands[0], "-vf", expectedFilterChain) + self.assert_token_pair(commands[1], "-vf", expectedFilterChain) + def test_av1_run_job_emits_file_level_quality_and_preset_metadata(self): context = self.make_context(VideoEncoder.AV1) target_descriptor, source_descriptor = self.make_media_descriptors()