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

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

复制代码
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)
相关推荐
IvanCodes17 分钟前
从 ChatBot 到具身 Agent:我终于看懂 AI 的下一代交互入口
人工智能·agent
闵孚龙21 分钟前
Claude Code API通信层全解析:重试、流式、降级、Fast Mode、Prompt Cache 与 Files API 的底层工程
人工智能·架构·prompt
三产29 分钟前
Hermes 教程 02:配置详解
人工智能·hermes
2601_9577808431 分钟前
Claude Code 2026年最新部署指南:从环境搭建到技能扩展
前端·人工智能·ai编程·claude
dhashdoia36 分钟前
2026年GPT-5.5国内无障碍使用指南:星链4SAPI全链路部署
人工智能·gpt·ai作画·ai编程
zhangfeng11331 小时前
workbuddy 专家 “前端开发师” 结合nvidia-mistral-small-4-119b-2603 项目计划-前端界面开发.md
前端·人工智能·免费
向量引擎1 小时前
向量引擎、deepseek v4、GPT Image 2、api key:Agent 热潮下,AI 应用真正卷的是“调度能力
人工智能·gpt·aigc·ai编程·ai写作·agi·api调用
2601_957780841 小时前
GPT API工程化接入:从演示验证到生产部署的完整实践
大数据·人工智能·gpt·架构
王者鳜錸1 小时前
企业解决方案十二-网站、各类APP、人工智能定制开发
人工智能·app定制·网站定制·大模型定制·知识库定制
AI算力小知识1 小时前
国内 GPU 算力租赁平台深度测评:涵盖显卡资源、价格、性能、服务多维度
人工智能·gpu算力·ai算力