python 腾讯会议录屏文件转化为MP4

复制代码
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)
相关推荐
森语林溪21 小时前
大数据环境搭建从零开始(十七):JDK 17 安装与配置完整指南
java·大数据·开发语言·centos·vmware·软件需求·虚拟机
“负拾捌”21 小时前
LangChain提示词模版 PromptTemplate
python·langchain·prompt
合作小小程序员小小店1 天前
web安全开发,在线%服务器日志入侵检测%系统安全开发,基于Python,flaskWeb,正则表达式检测,mysql数据库
服务器·python·安全·web安全·flask·安全威胁分析·安全架构
dreams_dream1 天前
Django序列化器
后端·python·django
懷淰メ1 天前
python3GUI--短视频社交软件 By:Django+PyQt5(前后端分离项目)
后端·python·django·音视频·pyqt·抖音·前后端
lsx2024061 天前
HTML 音频(Audio)详解
开发语言
woshihonghonga1 天前
【动手学深度学习】
开发语言·python
威风的虫1 天前
ES6 数组方法:告别循环,拥抱函数式编程
开发语言·前端·javascript
码界筑梦坊1 天前
240-基于Python的医疗疾病数据可视化分析系统
开发语言·python·信息可视化·数据分析·毕业设计·echarts
2301_803554521 天前
C++ 锁类型大全详解
开发语言·c++