import os
import ffmpeg
from ffmpeg import output, run
def convert_wemtv_to_mp4(input_file, output_dir):
"""
将 WEMTV 文件转换为 MP4 文件并保存
Args:
input_file (str): 输入 WEMTV 文件路径
output_dir (str): 输出 MP4 文件保存目录
"""
try:
if os.path.exists(input_file):
print(f"input_file:存在")
# 检查输出目录是否存在
if not os.path.exists(output_dir):
os.makedirs(output_dir)
print(f"output_dir:不存在")
# 构建输出文件路径
output_file = os.path.join(output_dir, output_dir + ".mp4")
print(f"input_file:{input_file}")
# 创建 FFmpeg 处理流
stream = input(input_file)
print(f"stream:{stream}")
stream = output(stream, output_file, codec='libx264', f='mp4')
# 执行转换
run(stream)
print(f"转换成功: {output_file}")
except Exception as e:
print(f"转换失败: {input_file}")
print(e)
# 示例用法
input_file = 'path/to/input.wemtv'
output_file = 'path/to/output.mp4'
output_dir = 'directory'
convert_wemtv_to_mp4(input_file, output_dir)
python 腾讯会议录屏文件转化为MP4
@小张不嚣张2024-08-28 19:32
相关推荐
529宝宝起名网18 分钟前
用 Python 开发历史名字查询与起名灵感工具:从古籍人物数据库到名字文化故事生成用户2986985301430 分钟前
Python 将 HTML 转换为 Word 文档的实践指南维克兜率天32 分钟前
【维克】模块3总结:从一行空数据,到一个能跑的模型飞Link36 分钟前
定积分理论与 Python 仿真完全指南小静AI工程实验室43 分钟前
Python 爬虫翻页为何重复、漏数据?SQLite 复现 OFFSET、复合游标与快照的 8 项检查ocean210344 分钟前
2025-2026年C++专题大厂面试高频问题夜雪一千1 小时前
如何使用Python实现音频转文本(ASR语音识别)白远山1 小时前
健身场馆无人自动化系统实战指南:从架构设计到部署全流程解析SunnyDays10111 小时前
使用 Python 将 PowerPoint 转换为视频(无需安装 Microsoft PowerPoint)飞Link1 小时前
零基础:离散数据积分与 Python 实现保姆级教程