视频添加字幕

1、依靠ffmpeg 命令

java 复制代码
package zimu;

import java.io.IOException;


public class TestSrt {

    public static void main(String[] args) {
        String videoFile = "/test/test1.mp4";
        String subtitleFile = "/test/test1.SRT";
        String outputFile = "/test/testout13.mp4";

        try {
            // 使用FFmpeg命令行生成视频字幕
            String command = "D:\\test\\ffmpeg.exe -i " + videoFile + " -filter_complex \"subtitles=" + subtitleFile + "\" -c:a copy " + outputFile;
            System.out.println(command);
            Runtime.getRuntime().exec(command);
            System.out.println("视频字幕生成完成");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

2、SRT 文件格式:

参考链接: https://blog.csdn.net/liuyaokai1990/article/details/110417483?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-0-110417483-blog-109305411.235^v38^pc_relevant_sort_base3&spm=1001.2101.3001.4242.1&utm_relevant_index=3

相关推荐
DevOpenClub44 分钟前
职教高考控制线 API:招生类别枚举、筛选与空分数含义
java·数据库·高考
露天赏雪2 小时前
第3篇:Sentinel熔断降级实战:大模型接口抖动时的服务兜底方案
java·开发语言·人工智能·spring boot·spring·servlet·sentinel
天天被压力2 小时前
【A股分钟级高频数据完全手册 #06】北交所分钟级数据接口:京市股票Pro版最新分时
java·人工智能·python
天天被压力2 小时前
【A股分钟级高频数据完全手册 #05】指数历史分钟数据接口:Pro版沪深指数分时回放
java·人工智能·python
captain3762 小时前
▲统一功能——DispatcherServlet源码分析
java·spring·java-ee·log4j·maven
金銀銅鐵2 小时前
JDK 21 中 List.of 的实现细节:从 List12 到 ListN
java·后端·ai编程
yeccheng4 小时前
MySQL 索引超详解:从底层 B+ 树到面试高频考点
java·开发语言·jvm·mysql·面试
这个昵称不容易4 小时前
SpringBoot 读书笔记共享平台部署实战:97 个 Java 文件 / 113 个接口 / 10 张表
java·springboot·毕设
金銀銅鐵7 小时前
一个 Java 文件实现《孫子兵法·始計篇》中英对照阅读器
java·后端·ai编程
DevOpenClub7 小时前
高考教育信息问答 API:会话参数、资料引用与流式响应
java·数据库·高考