From 19c09211790ef2715350176a9b7551dabede9612 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 13 Oct 2021 00:07:20 -0300 Subject: [PATCH] ges:tests: Create shorter assets to avoid timeouts And use a simple GStreamer pipeline as testsrcbin with GstTranscoder doesn't let us easily set the framerate of the source and we end up having videorate dropping frames leading to the rendered file having an unprecise duration. This should fix races with `check.gst-editing-services.pythontests.pyunittest.python.test_assets.TestTimeline.test_reload_asset` Part-of: --- .../gst-editing-services/tests/check/python/common.py | 13 +++++++++---- .../gst-editing-services/tests/check/python/test_assets.py | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/subprojects/gst-editing-services/tests/check/python/common.py b/subprojects/gst-editing-services/tests/check/python/common.py index 1593d68..a07fd8f 100644 --- a/subprojects/gst-editing-services/tests/check/python/common.py +++ b/subprojects/gst-editing-services/tests/check/python/common.py @@ -18,6 +18,7 @@ # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301, USA. +from urllib.parse import urlparse import gi gi.require_version("Gst", "1.0") @@ -116,13 +117,17 @@ def can_generate_assets(): @contextlib.contextmanager -def created_video_asset(uri=None, num_bufs=30): +def created_video_asset(uri=None, num_bufs=30, framerate="30/1"): with tempfile.NamedTemporaryFile(suffix=".ogg") as f: if not uri: uri = Gst.filename_to_uri(f.name) - transcoder = GstTranscoder.Transcoder.new("testbin://video,num-buffers=%s" % num_bufs, - uri, "application/ogg:video/x-theora:audio/x-vorbis") - transcoder.run() + name = f.name + else: + name = urlparse(uri).path + pipe = Gst.parse_launch(f"videotestsrc num-buffers={num_bufs} ! video/x-raw,framerate={framerate} ! theoraenc ! oggmux ! filesink location={name}") + pipe.set_state(Gst.State.PLAYING) + assert pipe.get_bus().timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.EOS) + pipe.set_state(Gst.State.NULL) yield uri diff --git a/subprojects/gst-editing-services/tests/check/python/test_assets.py b/subprojects/gst-editing-services/tests/check/python/test_assets.py index e33c623..9e6f643 100644 --- a/subprojects/gst-editing-services/tests/check/python/test_assets.py +++ b/subprojects/gst-editing-services/tests/check/python/test_assets.py @@ -62,17 +62,17 @@ class TestTimeline(GESSimpleTimelineTest): @unittest.skipUnless(*common.can_generate_assets()) def test_reload_asset(self): - with common.created_video_asset() as uri: + with common.created_video_asset(num_bufs=2, framerate="2/1") as uri: asset0 = GES.UriClipAsset.request_sync(uri) self.assertEqual(asset0.props.duration, Gst.SECOND) - with common.created_video_asset(uri, 60) as uri: + with common.created_video_asset(uri, 4, framerate="2/1") as uri: GES.Asset.needs_reload(GES.UriClip, uri) asset1 = GES.UriClipAsset.request_sync(uri) self.assertEqual(asset1.props.duration, 2 * Gst.SECOND) self.assertEqual(asset1, asset0) - with common.created_video_asset(uri, 90) as uri: + with common.created_video_asset(uri, 6, framerate="2/1") as uri: mainloop = common.create_main_loop() def asset_loaded_cb(_, res, mainloop): asset2 = GES.Asset.request_finish(res) -- 2.7.4