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)
相关推荐
凯瑟琳.奥古斯特20 分钟前
力扣1235:加权区间调度最优解
java·python·算法·leetcode·职场和发展
_童年的回忆_24 分钟前
【php】在linux下PHP安装amqp扩展
linux·开发语言·php
郑洁文41 分钟前
基于Python的网络入侵检测系统
网络·python·php
AIMath~1 小时前
python中的uv命令揭秘
开发语言·python·uv
弹简特1 小时前
【零基础学Python】06-Python模块和包、异常处理、文件常用操作
开发语言·python
x***r1511 小时前
Postman-win64-7.2.2-Setup安装步骤详解(附API接口测试与参数配置教程)
开发语言·lua
念恒123061 小时前
Python 面向对象编程核心:对象、实例化、封装与变量作用域
开发语言·python
薛定谔的悦1 小时前
光伏-储能-负荷联合预测:给 EMS 装上“预知能力“
java·数据库·人工智能·python·储能
大菜菜小个子1 小时前
template<typename T>使用
java·开发语言·算法
L_09071 小时前
【C++】C++11 新特性
开发语言·c++