python : 打开文件夹,选择视频文件,并播放
2018-03-07 23:21
921 查看
openvideo.py
python 3.x 的写法:
如果你的PC安装了[ 格式工厂 ]这个应用软件,那么实际安装了Windows版的 FFmpeg
在D:\FormatFactory\FFModules\Encoder\ 能找到 mplayer.exe 和 ffmpeg.exe
这里谈谈 mplayer 简单应用:mplayer -h
1. 播放比例调整
mplayer -aspect 16:9 <videofile>
mplayer -aspect 4:3 <videofile>
2. 控制热键
基本播放
→ 前进10秒
← 后退10秒
↑ 前进60秒
↓ 后退60秒
PageUP 前进10分钟
PageDown 后退10分钟
Enter 全屏开关
Space 暂停开关
Esc 退出
q 退出
ffmpeg.exe -h
比如:将.MPG文件转换格式为.avi文件
D:\FFModules\Encoder\ffmpeg.exe -i F1.MPG -f avi -s 320x240 -y F1.avi
批量转换脚本 mpg2avi.py
对 free pascal 有兴趣的可以下载
https://download.csdn.net/download/belldeep/10292125
# -*- coding: cp936 -*- import os, sys import tkFileDialog fname = tkFileDialog.askopenfilename(initialdir='E:/VIDEO') print fname os.system("D:\FFModules\Encoder\mplayer.exe -aspect 4:3 "+ fname.encode('cp936'))
python 3.x 的写法:
# -*- coding: cp936 -*- import os, sys from tkinter import filedialog fname = filedialog.askopenfilename(initialdir='E:/VIDEO') print(fname) os.system(r"D:\FFModules\Encoder\mplayer.exe -aspect 16:9 "+ fname)
如果你的PC安装了[ 格式工厂 ]这个应用软件,那么实际安装了Windows版的 FFmpeg
在D:\FormatFactory\FFModules\Encoder\ 能找到 mplayer.exe 和 ffmpeg.exe
这里谈谈 mplayer 简单应用:mplayer -h
1. 播放比例调整
mplayer -aspect 16:9 <videofile>
mplayer -aspect 4:3 <videofile>
2. 控制热键
基本播放
→ 前进10秒
← 后退10秒
↑ 前进60秒
↓ 后退60秒
PageUP 前进10分钟
PageDown 后退10分钟
Enter 全屏开关
Space 暂停开关
Esc 退出
q 退出
ffmpeg.exe -h
比如:将.MPG文件转换格式为.avi文件
D:\FFModules\Encoder\ffmpeg.exe -i F1.MPG -f avi -s 320x240 -y F1.avi
批量转换脚本 mpg2avi.py
import os, sys import glob if len(sys.argv) ==2: pattern = sys.argv[1] else: print 'usage: mpg2avi.py *.MPG ' sys.exit(1) maps ={} for f1 in glob.glob(pattern): if os.path.isfile(f1): fn,ext = os.path.splitext(f1) if ext not in ('.mpg','.MPG'): break f2 = fn +'.avi' if os.path.exists(f2): print f2,'is already exists' else: os.system("D:\\FFModules\\Encoder\\ffmpeg.exe -i %s -f avi -s 320x240 -y %s" %(f1,f2)) print f1,'=>',f2 else: print f1,'is not file' break #
对 free pascal 有兴趣的可以下载
https://download.csdn.net/download/belldeep/10292125
相关文章推荐
- python qt(pyqt)的文件打开、文件保存、文件夹选择对话框
- 使用C#选择文件夹、打开文件夹、选择文件
- 使用C#选择文件夹、打开文件夹、选择文件
- c# 打开、保存文件对话框 和 文件夹选择对话框
- python删除文件夹下相同文件和无法打开的图片
- Android入门:弹出框选择文件夹目录 以及启用新的Task打开文件
- [Win32]打开文件/保存文件/选择文件夹对话框
- 使用C#选择文件夹、打开文件夹、选择文件
- c#winform选择文件,文件夹,打开指定目录方法
- <Qt C++>选择文件\选择文件夹\label播放gif
- [转]C#中调用资源管理器(Explorer.exe)打开指定文件夹 + 并选中指定文件 + 调用(系统默认的播放类)软件(如WMP)打开(播放歌曲等)文件
- c#winform选择文件,文件夹,打开指定目录方法
- android 文件浏览。打开sdcard文件夹。只显示文件夹和txt文件。选择txt文件返回其名字
- php 网页播放器用来播放在线视频的代码(自动判断并选择视频文件类型)
- 打开含avi格式视频文件的文件夹“死机”问题的解决
- Python——利用相对路径,在当前目录(即,编程目录)下打开文件或文件夹的方法
- C#选择文件、选择文件夹、打开文件(或者文件夹)
- c#winform选择文件,文件夹,打开指定目录方法
- 如何用c#打开文件夹并选择文件夹内的一个文件 open folder and select file
- 使用C#选择文件夹、打开文件夹、选择文件