From d5092340667fa08c674bb8e8877cbfeb14e54ed4 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 15 Feb 2022 15:29:40 +0100 Subject: [PATCH 1/4] OP-2646 - fix for proper parsing of ffmpeg output arguments Previous implementation was too simple, values that contained flags anywhere inside were triggering it. --- openpype/plugins/publish/extract_review.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/plugins/publish/extract_review.py b/openpype/plugins/publish/extract_review.py index d223c31291..5f286a53e6 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -694,13 +694,13 @@ class ExtractReview(pyblish.api.InstancePlugin): audio_args_dentifiers = ["-af", "-filter:a"] for arg in tuple(output_args): for identifier in video_args_dentifiers: - if identifier in arg: + if arg.startswith("{} ".format(identifier)): output_args.remove(arg) arg = arg.replace(identifier, "").strip() video_filters.append(arg) for identifier in audio_args_dentifiers: - if identifier in arg: + if arg.startswith("{} ".format(identifier)): output_args.remove(arg) arg = arg.replace(identifier, "").strip() audio_filters.append(arg) From b292438e2b8d36852b459a834740fa8d2056c335 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 15 Feb 2022 16:17:11 +0100 Subject: [PATCH 2/4] OP-2646 - added barebone unit test for ffmpeg_full_args_filters --- .../plugins/publish/test_extract_review.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/unit/openpype/plugins/publish/test_extract_review.py diff --git a/tests/unit/openpype/plugins/publish/test_extract_review.py b/tests/unit/openpype/plugins/publish/test_extract_review.py new file mode 100644 index 0000000000..0a48d3d059 --- /dev/null +++ b/tests/unit/openpype/plugins/publish/test_extract_review.py @@ -0,0 +1,30 @@ +from openpype.plugins.publish.extract_review import ExtractReview + + +def test_fix_ffmpeg_full_args_filters(): + """Tests because of wrong resolution of audio filters.""" + plugin = ExtractReview() + output_arg = "c:/test-afbdc" + ret = plugin.ffmpeg_full_args([], [], [], [output_arg]) + assert len(ret) == 2, "Parsed wrong" + assert ret[-1] == output_arg + + ret = plugin.ffmpeg_full_args([], [], ["adeclick"], [output_arg]) + assert len(ret) == 4, "Parsed wrong" + assert ret[-1] == output_arg + assert ret[-2] == '"adeclick"' + assert ret[-3] == "-filter:a" + + ret = plugin.ffmpeg_full_args([], [], [], [output_arg, "-af adeclick"]) + assert len(ret) == 4, "Parsed wrong" + assert ret[-1] == output_arg + assert ret[-2] == '"adeclick"' + assert ret[-3] == "-filter:a" + + ret = plugin.ffmpeg_full_args([], [], ["adeclick"], + [output_arg, "-af adeclick"]) + assert len(ret) == 4, "Parsed wrong" + assert ret[-1] == output_arg + assert ret[-2] == '"adeclick,addeclick"' # TODO fix this duplication + assert ret[-3] == "-filter:a" + From 21784799c318cf339fbbd8fea7ed1cd4dae3a921 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 15 Feb 2022 16:19:00 +0100 Subject: [PATCH 3/4] OP-2646 - modified readme --- tests/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/README.md b/tests/README.md index d0578f8059..6fb86cd027 100644 --- a/tests/README.md +++ b/tests/README.md @@ -12,8 +12,6 @@ Structure: How to run: ---------- -- single test class could be run by PyCharm and its pytest runner directly -- OR - use Openpype command 'runtests' from command line (`.venv` in ${OPENPYPE_ROOT} must be activated to use configured Python!) -- `${OPENPYPE_ROOT}/python start.py runtests` From 260257089c86cfd457e4564b1ae647b670194798 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 15 Feb 2022 16:26:17 +0100 Subject: [PATCH 4/4] OP-2646 - Hound --- tests/unit/openpype/plugins/publish/test_extract_review.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unit/openpype/plugins/publish/test_extract_review.py b/tests/unit/openpype/plugins/publish/test_extract_review.py index 0a48d3d059..48317f0eb9 100644 --- a/tests/unit/openpype/plugins/publish/test_extract_review.py +++ b/tests/unit/openpype/plugins/publish/test_extract_review.py @@ -25,6 +25,5 @@ def test_fix_ffmpeg_full_args_filters(): [output_arg, "-af adeclick"]) assert len(ret) == 4, "Parsed wrong" assert ret[-1] == output_arg - assert ret[-2] == '"adeclick,addeclick"' # TODO fix this duplication + assert ret[-2] == '"adeclick,adeclick"' # TODO fix this duplication assert ret[-3] == "-filter:a" -