视频添加字幕

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

相关推荐
q***07141 小时前
Spring Boot 多数据源解决方案:dynamic-datasource-spring-boot-starter 的奥秘(上)
java·spring boot·后端
q***49861 小时前
Spring Boot 3.4 正式发布,结构化日志!
java·spring boot·后端
沐浴露z3 小时前
【微服务】基本概念介绍
java·微服务
Z3r4y4 小时前
【代码审计】RuoYi-4.7.3&4.7.8 定时任务RCE 漏洞分析
java·web安全·ruoyi·代码审计
Kuo-Teng5 小时前
LeetCode 160: Intersection of Two Linked Lists
java·算法·leetcode·职场和发展
Jooou5 小时前
Spring事务实现原理深度解析:从源码到架构全面剖析
java·spring·架构·事务
盖世英雄酱581366 小时前
commit 成功为什么数据只更新了部分?
java·数据库·后端
码上淘金7 小时前
在 YAML 中如何将 JSON 对象作为字符串整体赋值?——兼谈 Go Template 中的 fromJson 使用
java·golang·json
刘一说7 小时前
Spring Boot 应用的指标收集与监控体系构建指南
java·spring boot·后端