-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangingResolution.py
More file actions
59 lines (42 loc) · 1.47 KB
/
changingResolution.py
File metadata and controls
59 lines (42 loc) · 1.47 KB
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
from gi.repository import Gtk
from gi.repository import GES
from gi.repository import Gst
from gi.repository import GObject
import signal
video_path = "/home/cfoch/Videos/samples/big_buck_bunny_1080p_stereo.ogg"
width = 480
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 = "file://" + video_path
timeline = GES.Timeline.new_audio_video()
layer = timeline.append_layer()
asset = GES.UriClipAsset.request_sync(video_uri)
clip = layer.add_asset(asset, 0, 0, asset.get_duration(), GES.TrackType.UNKNOWN)
timeline.commit()
videotrack = timeline.get_tracks()[0]
caps = Gst.caps_from_string("video/x-raw, width=%s, height=%s" % (width, height))
# videotrack.set_property("restriction-caps", caps)
videotrack.set_restriction_caps(caps)
print videotrack.get_caps()
pipeline = GES.Pipeline()
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()