operate()在java的意思_ffmpeg-operate

USE 使用

org.mountcloud

ffmpeg-operate

1.0

English

Description

The prerequisite for this project is that FFMPEG is installed in the environment and FFMPEG commands can be used in the console. This project is very convenient for java to use FFMPEG function.

There are 3 built-in video operations in the project, 1: video format is changed to M3U8 (FFMpegVideoFormatM3u8), 2: view video attribute (FFMpegVideoInfo), 3: video screenshot (FFMpegVideoScreenShot). It can also be extended by inheriting FFMpegOperationBase.

Features

1: You can get the execution percentage progress of the task.

2: Very high scalability.

3: Multi-threaded mode of operation.

4: Tasks can be performed synchronously or asynchronously.

中文

描述

这个项目使用的前提条件是环境中安装了FFMPEG,并且可以在控制台中使用FFMPEG命令。本项目极大方便了java使用FFMPEG功能。

项目中内置了3个对视频的操作,1:视频格式转为M3U8(FFMpegVideoFormatM3u8),2:查看视频属性(FFMpegVideoInfo),3:视频截图(FFMpegVideoScreenShot)。还可以通过继承FFMpegOperationBase来进行扩展。

特点

1:可以获取任务的执行百分比进度。

2:非常高的可扩展性。

3:多线程方式进行操作。

4:可同步或异步执行。

Demo 用例

@Test

public void convertM3u8() {

//create result bean

FFVideoInfoResult result = new FFVideoInfoResult();

//find video info

FFMpegVideoInfo ffMpegVideoInfo = new FFMpegVideoInfo();

ffMpegVideoInfo.setVideoUrl("D:\\cma_15307640036trzll1p.mp4");

FFMepgVideoInfoTask videoInfoTask = new FFMepgVideoInfoTask(result,ffMpegVideoInfo);

FFTaskContext.getContext().submit(videoInfoTask,null);

String bitrate = "5286k";

//create to m3u8 operation

FFMpegVideoFormatM3u8 m3u8Operation = new FFMpegVideoFormatM3u8();

m3u8Operation.setVideoFileName("D:\\cma_15307640036trzll1p.mp4");

m3u8Operation.setBitrate(bitrate);

m3u8Operation.setTimes(5);

m3u8Operation.setM3u8File("D:\\cma_15307640036trzll1p\\cma_15307640036trzll1p.m3u8");

m3u8Operation.setTsFiles("D:\\cma_15307640036trzll1p\\cma_15307640036trzll1p%5d.ts");

//to m3u8 task

FFMepgVideoFormatM3u8Task task = new FFMepgVideoFormatM3u8Task(m3u8Operation);

//add task

FFTaskContext.getContext().addTask(task);

while(!task.getProgress().getState().equals(FFTaskStateEnum.COMPLETE)){

try {

Thread.sleep(2000);

} catch (InterruptedException e) {

}

}

System.out.println("COMPLETE");

}

note 笔记

1: FFTaskContext.getContext().addTask(task) is an asynchronous task, FFTaskContext.getContext().submit(taks) is a synchronous task.

1:FFTaskContext.getContext().addTask(task) 为异步任务,FFTaskContext.getContext().submit(taks)为同步任务

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值