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)
相关推荐
言乐62 分钟前
Python实现可运行解密游戏游戏框架
python·游戏·小程序·游戏程序·关卡设计
YUS云生27 分钟前
Python学习笔记·第31天:FastAPI入门——路由、路径参数、查询参数与请求体
笔记·python·学习
玖玥拾40 分钟前
C# 语言进阶(十五)C# 游戏服务端 MySQL 数据库
服务器·开发语言·网络·数据库·mysql·c#
智写-AI1 小时前
真实有效的免费降英文AI工具服务商
人工智能·python
铅笔侠_小龙虾1 小时前
Rust 学习目录
开发语言·学习·rust
yuhuofei20211 小时前
【Python入门】了解掌握Python中函数的基本使用
python
云泽8082 小时前
从零吃透 C++ 异常:抛出捕获、栈展开、异常重抛与编码规范详解
开发语言·c++·代码规范
灯澜忆梦2 小时前
GO---可见性规则
开发语言·golang
逝水无殇2 小时前
C# 文件的输入与输出详解
开发语言·数据库·后端·c#