0
다음 코드를 사용하여 비디오를 창에 표시합니다. 누군가 나를 도울 수 있고 비디오 파일의 비디오 해상도 (폭 x 높이)를 추출 할 수있는 간단한 파이썬 예제를 제공 할 수 있습니까?Python : Gst 비디오 재생 빈에서 비디오 해상도를 얻으려면 어떻게해야합니까?
며칠이 지나서야 붙어 있습니다 ... 도움을 주시면 감사하겠습니다.
import os
import Tkinter as tkinter
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstVideo', '1.0')
from gi.repository import Gst, GObject, GstVideo
def set_frame_handle(bus, message, frame_id):
if not message.get_structure() is None:
if message.get_structure().get_name() == 'prepare-window-handle':
display_frame = message.src
display_frame.set_property('force-aspect-ratio', True)
display_frame.set_window_handle(frame_id)
window = tkinter.Tk()
window.title('')
window.geometry('400x300-30-100')
Gst.init(None)
GObject.threads_init()
display_frame = tkinter.Frame(window, bg='')
display_frame.place(relx = 0, rely = 0, anchor = tkinter.NW, relwidth = 1, relheight = 1)
frame_id = display_frame.winfo_id()
player = Gst.ElementFactory.make('playbin', None)
filepath = os.path.realpath('kbps.mp4')
filepath2 = "file:///" + filepath.replace('\\', '/').replace(':', '|')
print filepath2
player.set_property('uri', filepath2)
player.set_state(Gst.State.PLAYING)
bus = player.get_bus()
bus.enable_sync_message_emission()
bus.connect('sync-message::element', set_frame_handle, frame_id)
window.geometry('400x300+30+300')
window.update
window.mainloop()
감사합니다. –