python控制视频播放器的大小与位置_如何在pythontkinter中使用GStreamer在视频播放器中调整大小和裁剪?...

我用python编写了一个小型的媒体播放器,使用了嵌入在我的应用程序中的TKinter和GStreamer。播放器基于下面的代码,这是对Way to play video files in Tkinter?的一个小修改。在import os, sys

import Tkinter as tkinter

import threading

import gi

gi.require_version('Gst', '1.0')

gi.require_version('GstVideo', '1.0')

gi.require_version('GdkX11', '3.0')

from gi.repository import Gst, GObject, GdkX11, GstVideo

def set_frame_handle(bus, message, frame_id):

if not message.get_structure() is None:

print message.get_structure().get_name()

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('500x400')

GObject.threads_init()

Gst.init(None)

display_frame = tkinter.Canvas(window, bg='#030')

display_frame.pack(side=tkinter.TOP,expand=tkinter.YES,fill=tkinter.BOTH)

frame_id = display_frame.winfo_id()

player = Gst.ElementFactory.make('playbin', None)

filepath = os.path.realpath('kbps.mp4')

filepath2 = "file:///" + filepath.replace('\\', '/').replace(':', '|')

player.set_property('uri', filepath2)

bus = player.get_bus()

bus.enable_sync_message_emission()

bus.connect('sync-message::element', set_frame_handle, frame_id)

player.set_state(Gst.State.PLAYING)

window.mainloop()

我需要放大视频的某个部分,因此我需要使用GStreamer基本插件,称为videocrop和videoscale,它们都是GStreamer 1.0的一部分。在

不幸的是,在花了几天的研究之后,我还没有找到一个简单的python示例来说明如何在TKiinter中使用这些插件(我没有使用Gtk或任何其他库)。在

有人能给我举个例子来说明如何使用这些工具吗?任何帮助都将不胜感激。提前谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值