Using scenechange to obtain scene timestamps programatically

Francisco Ayala Le Brun francisco at videowindow.eu
Tue Feb 22 09:23:36 UTC 2022


To whom it may concern,

I am trying to use gstreamer in order to take screenshots of a video
each time the scene changes. As a first step, I am attempting to get a
list of timestamps corresponding to each scene change.

In the documentation of the scenechange element, it is stated that a
signal is emitted every time the scene changes. However, the name of the
signal is not mentioned, and looking at the code, specifically lines
245-257 of scenechange.c, I can see no signal being emitted.
Source file is here:
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/a10b35c011b8291bae7b5da959f5a9d6b9a7cc0f/subprojects/gst-plugins-bad/gst/videofilters/gstscenechange.c

Thus I am now trying to catch the GstKeyForceUnit event in order to find
out when the scene changes. I do this by using the playbin element,
setting its video filter as the scenechange element, and then setting
the video-sink as a bin with a fakesink. The bin has a GhostPad which
prints events passing through it. However, while I can see scenechange's
debug messages, no GstKeyForceUnit events seem to pass through the GhostPad.
Here is the code: https://gist.github.com/fayalalebrun/6bb57cb6f3d730ec7d359cff69d5adcf

The log I see is as follows:
Reconfigure(Reconfigure(Event { ptr: 0x56036f43e030, type: "reconfigure", seqnum: Seqnum(4), structure: None }))
Latency(Latency(Event { ptr: 0x7fa5680a06c0, type: "latency", seqnum: Seqnum(345), structure: Some(GstEventLatency, latency=(guint64)0;) }))
0:00:00.806090337 26542 0x7fa580023920 INFO             scenechange gstscenechange.c:246:gst_scene_change_transform_frame_ip:<scenechange0> 0 407.956 22.8788 0.0560816 1
0:00:01.080411411 26542 0x7fa580023920 INFO             scenechange gstscenechange.c:246:gst_scene_change_transform_frame_ip:<scenechange0> 0 115.526 31.0005 0.268341 1
0:00:01.274231698 26542 0x7fa580023920 INFO             scenechange gstscenechange.c:246:gst_scene_change_transform_frame_ip:<scenechange0> 0 755.079 22.5827 0.0299078 1
0:00:01.349182752 26542 0x7fa580023920 INFO             scenechange gstscenechange.c:246:gst_scene_change_transform_frame_ip:<scenechange0> 0 27.9868 30.45 1.08801 1
0:00:01.689698365 26542 0x7fa580023920 INFO             scenechange gstscenechange.c:246:gst_scene_change_transform_frame_ip:<scenechange0> 0 801.204 37.4627 0.046758 1
0:00:02.063346606 26542 0x7fa580023920 INFO             scenechange gstscenechange.c:246:gst_scene_change_transform_frame_ip:<scenechange0> 0 14.1078 38.7118 2.74401 1
0:00:02.797156784 26542 0x7fa580023920 INFO             scenechange gstscenechange.c:246:gst_scene_change_transform_frame_ip:<scenechange0> 0 6.56696 29.0186 4.41888 1
0:00:03.083369457 26542 0x7fa580023920 INFO             scenechange gstscenechange.c:246:gst_scene_change_transform_frame_ip:<scenechange0> 0 14.522 37.9089 2.61045 1
0:00:03.347006242 26542 0x7fa580023920 INFO             scenechange gstscenechange.c:246:gst_scene_change_transform_frame_ip:<scenechange0> 0 10.5185 35.7488 3.39866 1
  C-c C-c

As you can see, a couple of events are printed at the beginning, but not
the GstKeyForceUnit event I am interested in.

Thank you in advance,
Francisco Ayala


More information about the gstreamer-devel mailing list