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)
相关推荐
Zane19946 小时前
@property 到底是怎么把方法伪装成属性的?一文吃透 property、staticmethod、classmethod
后端·python
qq_316411036 小时前
AI 情感陪伴智能潮玩软硬件一体化开发案例
人工智能·python
废弃的小码农7 小时前
功能测试--Day07--Python编程基础
开发语言·python
zx1154507 小时前
大模型工具调用次数限制
人工智能·python
fengci.7 小时前
Microweber CMS 未授权路径穿越漏洞(CVE-2026-65694)
android·开发语言·前端·学习·php
MC皮蛋侠客7 小时前
SQLAlchemy 系列(八):AsyncIO、并发与 Web 生命周期——让每个并发任务持有自己的 Session
数据库·python
程序员zgh7 小时前
C++ 拷贝赋值运算符 详解
c语言·开发语言·c++
念何架构之路7 小时前
restartmanager-重启管理子系统
java·开发语言
SomeB1oody8 小时前
【RustyML入门】2.0. 经典机器学习
开发语言·后端·机器学习·rust·教程
大数据魔法师8 小时前
Python 网络请求库 curl_cffi:从入门到实战,如何规避网站指纹检测
python·数据分析