mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1130>
This commit is contained in:
parent
fbee6c8b23
commit
19c0921179
2 changed files with 12 additions and 7 deletions
|
@ -18,6 +18,7 @@
|
||||||
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
from urllib.parse import urlparse
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
gi.require_version("Gst", "1.0")
|
gi.require_version("Gst", "1.0")
|
||||||
|
@ -116,13 +117,17 @@ def can_generate_assets():
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@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:
|
with tempfile.NamedTemporaryFile(suffix=".ogg") as f:
|
||||||
if not uri:
|
if not uri:
|
||||||
uri = Gst.filename_to_uri(f.name)
|
uri = Gst.filename_to_uri(f.name)
|
||||||
transcoder = GstTranscoder.Transcoder.new("testbin://video,num-buffers=%s" % num_bufs,
|
name = f.name
|
||||||
uri, "application/ogg:video/x-theora:audio/x-vorbis")
|
else:
|
||||||
transcoder.run()
|
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
|
yield uri
|
||||||
|
|
||||||
|
|
|
@ -62,17 +62,17 @@ class TestTimeline(GESSimpleTimelineTest):
|
||||||
|
|
||||||
@unittest.skipUnless(*common.can_generate_assets())
|
@unittest.skipUnless(*common.can_generate_assets())
|
||||||
def test_reload_asset(self):
|
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)
|
asset0 = GES.UriClipAsset.request_sync(uri)
|
||||||
self.assertEqual(asset0.props.duration, Gst.SECOND)
|
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)
|
GES.Asset.needs_reload(GES.UriClip, uri)
|
||||||
asset1 = GES.UriClipAsset.request_sync(uri)
|
asset1 = GES.UriClipAsset.request_sync(uri)
|
||||||
self.assertEqual(asset1.props.duration, 2 * Gst.SECOND)
|
self.assertEqual(asset1.props.duration, 2 * Gst.SECOND)
|
||||||
self.assertEqual(asset1, asset0)
|
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()
|
mainloop = common.create_main_loop()
|
||||||
def asset_loaded_cb(_, res, mainloop):
|
def asset_loaded_cb(_, res, mainloop):
|
||||||
asset2 = GES.Asset.request_finish(res)
|
asset2 = GES.Asset.request_finish(res)
|
||||||
|
|
Loading…
Reference in a new issue