删除视频最后几帧 剪切视频

删除视频最后几帧 剪切视频

复制代码
remove_last.py
python 复制代码
import subprocess
def remove_last_frame(input_file, output_file, frame_rate):
    command_duration = [
        'ffprobe',
        '-v', 'error',
        '-show_entries', 'format=duration',
        '-of', 'default=noprint_wrappers=1:nokey=1',
        input_file
    ]
    try:
        total_duration = float(subprocess.check_output(command_duration).strip())
        # 减去最后一帧的时长
        new_duration = total_duration - (5 / frame_rate)
        # 调用 ffmpeg 剪切视频
        command_ffmpeg = [
            'ffmpeg',
            '-i', input_file,
            '-t', str(new_duration),
            '-c', 'copy',  # 不重新编码
            '-y',  # 强制覆盖输出文件
            output_file
        ]

        subprocess.run(command_ffmpeg, check=True)
        print(f"Successfully removed the last frame from {input_file} and saved as {output_file}")

    except subprocess.CalledProcessError as e:
        print(f"Error occurred: {e}")

# 示例使用
input_file = r"E:\project\depth\buquan2\JpS7kM8\seg\mp4_all\blur\20201229_100633_861519_0_107_25.mp4"
output_file = input_file[:-4]+"_new.mp4"
frame_rate = 25

remove_last_frame(input_file, output_file, frame_rate)
相关推荐
JAI科研1 天前
Deepseek Agent Harness教程(二) | DeepSeek Harness 设计思路
人工智能·深度学习·算法·机器学习·自然语言处理·transformer·vllm
探物 AI1 天前
yolo目标检测中的激活函数对比
人工智能·yolo·目标检测
用户298698530141 天前
从入门到自动化:TXT 转 Word 的在线工具与代码实战方案
人工智能·后端·python
DeepIntelli1 天前
AI问答品牌推荐:如何用GEO让品牌出现在豆包、文心一言的答案里
人工智能
m4Rk_1 天前
【论文阅读】Agent 记忆机制(40):HiAgent——通过子目标级记忆提升长程任务执行能力
论文阅读·人工智能·学习·开源·github
还不秃顶的计科生1 天前
具身智能论文学习10:π0: A Vision-Language-Action Flow Model for General Robot Control
人工智能·深度学习·算法·机器学习·语言模型·vla·vlm
静开1 天前
Claude Code快速窥探:原来内核就是一个 while 循环外面套了八层壳
人工智能
AIyy8661 天前
定制化企业网盘深度解析:技术能力、落地场景与产品选型指南
人工智能
微学AI1 天前
把时间序列真正用起来:TimechoAI 使用与时序分析实战
数据库·人工智能·大模型
GEO_youxuan1 天前
AI财务分析软件到底是“自动出表“还是“决策推演“?从自动出表到决策推演的能力分层与选型逻辑
大数据·人工智能