用python写了一个超酷的视频转ASCII码的软件

UI设计

  • 浏览文件夹及输入视频地址框
  • 浏览文件夹及保存位置输入框
  • 颜色模式选择单选按钮
  • 视频缩放比例滑动刻度条
  • 程序执行结果输出滚动文本框
    在这里插入图片描述

tkinter

  • 设置窗口图标,将图片转换为base64编码形式以变量存放,代码运行时解码并转换为图片,图标设置完成之后删除图片。背景图片也是这样设置,base64编码过长就不放出来了
img=b'AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAlJSX/KSkp/y0tLf8wMDD/NjY2/0RERP+Dg4P/Pz8//x4eHv8hISH/IiIi/x0dHf8rKyv/Ly8v/4SEhP+jo6P/HBwc/yEhIf8mJib/KCgo/yEhIf9gYWH/PT4+/x4eHv8gICD/RERE/0xMTP8rKyv/ICAg/zExMf+QkJD/qKio/xoaGv8cHBz/HBwc/x4eHv8gICD/LS0t/x8fH/8fHx//LS0t/3l5ef9qamr/SkpK/yQkJP8oKSj/kZGQ/6ysrP8bGxv/HBwc/x0dHf8cHBz/Hx8f/yAgIP8hISH/NTY2/4OFhf+Xl5f/ampq/2JiYv8zNDL/Jycn/5OTk/+wsLD/Gxsb/xwcHP8dHR3/HR0d/x4eHv8hISH/RUVF/6Ghof/BwcH/tLS0/21ubP9FRkX/TU1N/yoqKv+VlZX/s7Oz/xwcHP8dHR3/HR0d/x0dHf8fHx//Pj4+/66urv/CwsL/ycnJ/7Gxsf89PT3/Nzc3/1tbW/89PT3/eXl5/7e3t/8cHBz/HR0d/x8fH/8fHx//JiYm/4qKiv/MzMz/w8PD/8rKyv+mpqb/QEBA/zs7O/9hYWH/VlZW/1tbW/+5ubn/HBwc/x0dHf8eHh7/ICAg/y0uLv/FxcX/1dXV/9XV1f/W1tb/1NTU/7Ozs/+Kior/bGxs/2JiYv9OTk3/t7e3/xwcHP8cHBz/HR0d/x8fH/8jJCT/ampp/8rKyv+Xl5b/i4yK/87Ozv/Dw8P/dnZ2/2hoaP9qamr/Q0ND/7e3t/8dHR3/Hh4e/x4eHv8fHx//KSkp/yoqKv9aWlr/dnZ2/4WFhf+np6f/iYmJ/y0tLf9LS0v/Y2Nj/1JSUv+/v7//MzQ0/zExMf8vLy//MzMz/6SkpP86Ojr/Jycn/3Nzc/+3t7b/r6+v/8zMzP9FRUX/MDAw/ysrK/9dXV3/v7+//0hJSf9FRUX/QkND/21ubv9nZ2f/RERE/yIiIv8nJyf/NDQ0/2tra/+en5//Ly8v/yMjI/8qKir/lJSU/729vf9ERUX/QENC/z4/P/9fYGD/V1dX/2lpaf8kJCT/Hx8f/yMjI/8pKSn/LCws/yIiIv8lJSX/Wlpa/66urv+6urr/MzMz/zExMf8uLi7/RkZG/15eXv8yMjL/KSkp/yoqKv8uLi7/KSkp/ycnJ/88Pj3/MjIy/2hoaP+mpqb/sLCw/yEhIf8gICD/Hx8f/x4eHv8dHR3/NjY2/yYmJv8cHBz/Hx8f/ycnJ/8mJib/aWpp/z4+Pv9tbW3/np6e/6Wlpf8vLy//MzQ0/y8vL/80NTX/MDAw/zU1Nf8gICD/Ghoa/xoaGv8aGhr/Kysr/0dHR/9BQUH/a2tr/5WUlf+bm5v/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=='
#设置窗口图标
tmp = open("tmp.ico","wb+")
tmp.write(base64.b64decode(img))
tmp.close()
root.iconbitmap("tmp.ico")
os.remove("tmp.ico")
  • 视频输入与保存位置,分别包含一个标签、一个文本输入框与一个按钮,通过place绝对定位将控件放到指定位置。
#选择输入视频:
tip1=Label(root, text='请选择输入视频(必填!):  ',font = ('楷体',25),bg='#CCCEC4',bd=0)
tip1.place(relx=0.1,rely=0.10,anchor=W)
#视频地址输入框
input_vedio_address= Entry(root,bg='#C4C7C5')
input_vedio_address.place(width=420,height=38,relx=0.1,rely=0.159,anchor=W)

#选择保存地址:
tip2=Label(root, text='请选择保存位置(必填!):  ',font = ('楷体',25),bg='#CCCEC4',bd=0)
tip2.place(relx=0.1,rely=0.24,anchor=W)
#保存地址输入框
input_save_address= Entry(root,bg='#C4C7C5')
input_save_address.place(width=420,height=38,relx=0.1,rely=0.30,anchor=W)

# “浏览文件夹”按钮
browse_folder_button = Button(root, text='浏览',font = ('楷体',15),bg="#C4C7C5",command=lambda :thread_it(browse_folder1))
browse_folder_button.place(relx=0.73,rely=0.159,anchor="w")

# “浏览文件夹”按钮
browse_folder_button = Button(root, text='浏览',font = ('楷体',15),bg='#C4C7C5',command=lambda :thread_it(browse_folder2))
browse_folder_button.place(relx=0.73,rely=0.30,anchor="w")
  • 选择颜色模式为radiobutton单选按钮,选择缩放比例为一个滑动刻度条,可以通过颜色模式选择ASCII码是否上色,缩放比例可以有效减少运行时间与提高视频可观赏性
#选择颜色模式
tip3=Label(root, text='请选择颜色模式               ',font = ('楷体',25),bg='#CCCEC4',bd=0)
tip3.place(width=500,relx=0.1,rely=0.385,anchor=W)
v=IntVar()
v.set(1)
radiobutton=Radiobutton(root,text='彩色',font = ('楷体',18),variable=v,value=1,bg='#CCCEC4')
radiobutton.place(relx=0.55,rely=0.385,anchor=W)
radiobutton=Radiobutton(root,text='黑白',font = ('楷体',18),variable=v,value=2,bg='#CCCEC4')
radiobutton.place(relx=0.65,rely=0.385,anchor=W)

#选择缩放比例
s=IntVar()
s.set(100)
scale=Scale(root, from_=0, to_=100, tickinterval=10, orient='horizontal',sliderrelief=RIDGE,bg='#CCCEC4',troughcolor='#D5CDC6',bd=0,resolution=10, variable=s,showvalue=False,length=500,borderwidth=0,label='请选择缩放比例!!!!!!数值越大越接近原视频,耗时更长;1080p(60~80),720p及以下(100)')
scale.place(relx=0.1,rely=0.49,anchor=W)

  • 程序运行通过一个滚动文本框输出,点击开始转换按钮程序开始运行
# “开始转换”按钮
browse_folder_button = Button(root, text='开始转换',font = ('楷体',15),bg='#C4C7C5',command=lambda :thread_it(run))
browse_folder_button.place(width=100,height=40,relx=0.75,rely=0.71,anchor="nw")

# ScrolledText组件(滚动文本框)
stext = ScrolledText(root, width=65, height=23, bg='#C4C7C5')
stext.place(width=420,height=300
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值