使用jcodec库修改mp4视频文件的标题和描述

亮子 2023-01-17 14:28:22 17451 0 0 0

1、添加依赖

        <dependency>
            <groupId>org.jcodec</groupId>
            <artifactId>jcodec</artifactId>
            <version>0.2.5</version>
        </dependency>

2、修改信息

    @Test
    public void setMp4Info1() {
        MetadataEditor mediaMeta = null;
        try {
            mediaMeta = MetadataEditor.createFrom(new
                    File("G:\\zhang-class\\2020-10-19\\2020-10-19讲解流程图.mp4"));

            Map<Integer, MetaValue> itunesMeta = mediaMeta.getItunesMeta();
            System.out.println(itunesMeta.toString());

            MetaValue metaValue = itunesMeta.get(0xA9636D74);
            System.out.println(metaValue);

            Map<Integer, MetaValue> meta = mediaMeta.getItunesMeta();
            meta.put(0xA9636D74, MetaValue.createString("http://www.shenmazong.com")); // fourcc for '©ART'
            mediaMeta.save(false); // fast mode is off



        } catch (IOException e) {
            e.printStackTrace();
        }
    }

参考文章