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)
相关推荐
典学长编程19 小时前
LangGraph 快速入门:从 StateGraph 到 ReAct Agent
python·有向图·无向图·langgraph·react agent·stategraph
风落青芜20 小时前
数据结构:堆的概念与实现
c语言·开发语言·数据结构·算法
用户019027581611 天前
AlphaFeed 查不到代码返回空?非法/缺后缀 symbol 的行为与处理
python
isfox1 天前
Python 单元测试:别再用 print 调试了,写个测试一劳永逸
python
用户298698530141 天前
在 Python 中把 Word 文档转换为 JSON 的三种实现方式
python·json·api
用户0332126663671 天前
使用 Python 删除 Excel 中的空白行或空白列
python·excel
databook1 天前
时间序列特征,哪些当时就能算出来
python·数据分析
kevin_org1 天前
LangChain入门学习(四)
python·学习·langchain·fastapi
H H.1 天前
Java企业级开发:从框架到工程化实战
java·开发语言·经验分享·其他·课程设计
特立独行的猫A1 天前
别再用 nohup 了:让应用在后台常驻的正确姿势与 systemd 服务详解
java·后端·python