-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimageSequence.py
66 lines (48 loc) · 1.62 KB
/
imageSequence.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import signal
from gi.repository import Gtk
from gi.repository import GES
from gi.repository import Gst
from gi.repository import GObject
path = "/home/cfoch/Pictures/Trash/bandas/%d.jpg"
width = 500
height = 360
def handle_sigint(sig, frame):
print "Bye!"
Gtk.main_quit()
def busMessageCb(unused_bus, message):
if message.type == Gst.MessageType.EOS:
print "EOS: The End"
Gtk.main_quit()
def duration_querier(pipeline):
print pipeline.query_position(Gst.Format.TIME)
return True
if __name__ == "__main__":
GObject.threads_init()
Gst.init(None)
GES.init()
video_uri = "multifile://" + path
# Setting Timeline.
timeline = GES.Timeline()
# Setting Track.
imgtrack = GES.VideoTrack.new()
timeline.add_track(imgtrack)
layer = GES.Layer.new()
timeline.add_layer(layer)
asset = GES.UriClipAsset.request_sync(video_uri)
clip = layer.add_asset(asset, 0, 0, 15 * Gst.SECOND, GES.TrackType.VIDEO)
source = clip.get_children(False)[0]
source.set_framerate(1, 1)
imgtrack.set_restriction_caps(Gst.caps_from_string("video/x-raw, height=320, width=400"))
# timeline.commit()
pipeline = GES.Pipeline.new()
pipeline.set_timeline(timeline)
pipeline.set_state(Gst.State.PLAYING)
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", busMessageCb)
GObject.timeout_add(300, duration_querier, pipeline)
signal.signal(signal.SIGINT, handle_sigint)
Gtk.main()
"""
gst-launch-1.0 multifilesrc location="%d.png" index=0 caps="image/png,framerate=1/1" ! pngdec ! videoconvert ! videorate ! xvimagesink
"""