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
相关推荐
小九九的爸爸4 小时前
前端想要入门Agent开发,要具备哪些Python基础?阿耶同学5 小时前
手把手教你用 LangGraph 搭建三层嵌套 Agent 架构花酒锄作田21 小时前
Pydantic校验配置文件hboot21 小时前
AI工程师第四课 - 深度学习入门ZhengEnCi1 天前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器ZhengEnCi1 天前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器曲幽1 天前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南用户8358086187911 天前
基于 Self-RAG 与列表级重排序的进阶 RAG 系统设计与实现Warson_L2 天前
Python `Annotated` 与 LangGraph Reducer 学习笔记韩师傅2 天前
海天线算法的前世今生