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
相关推荐
曲幽几秒前
FastAPI+Vue:文件分片上传+秒传+断点续传,这坑我帮你踩平了!哎嗨人生公众号2 分钟前
手写求导公式,让轨迹优化性能飞升,150ms变成9mscode_whiter9 分钟前
C++6(模板)一只旭宝16 分钟前
【C++ 入门精讲1】初始化、const、引用、内联函数 | 超详细手写笔记(附完整代码)石工记21 分钟前
Agent 应用与图状态编排框架LangGraphXiYang-DING25 分钟前
【Java】二叉搜索树(BST)Lyyaoo.26 分钟前
【JAVA基础面经】进程安全问题(synchronized and volatile)Andya_net36 分钟前
Java | 基于 Feign 流式传输操作SFTP文件传输赵优秀一一38 分钟前
FastAPI 核心无限进步_42 分钟前
【C++】多重继承中的虚表布局分析:D类对象为何有两个虚表?