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
相关推荐
BK贝壳5 小时前
bool-hybrid-array 的 GPU_opt 与 cjx:一个没显卡就报错的开关,一个把 800 字压到 96 字节的编码多加点辣也没关系9 小时前
JavaScript|第41章:性能优化实战BD_Marathon9 小时前
安装Jupyter notebookZlzxzw9 小时前
End-to-End Autonomous Generation of Human Assembly PlansResean02239 小时前
架构设计系列(十六):DDD 与代码架构Wellijohn9 小时前
2000 个请求、30% 失败率:我把 Python 批量并发的限流和重试参数算了一遍码途行者10 小时前
每天10分钟学Go:第22课 自定义错误23图10 小时前
C 语言开散列表(拉链法)拆解:链挂得没错,key=-1 会去读 T[-1]feixing_fx11 小时前
解构与展开:可读性和性能的取舍小飞在努力11 小时前
【实现负载均匀在线判题③】从零散模块到统一,编译运行全链路封装