时长信息转到video主体 增加多线程获取时间方法

This commit is contained in:
wangjinlei
2024-04-26 10:44:48 +08:00
parent 6b2e37b29b
commit 5c7d424f5e
11 changed files with 154 additions and 42 deletions

View File

@@ -5,11 +5,25 @@ import com.aliyun.teautil.models.RuntimeOptions;
import com.aliyun.vod20170321.Client;
import com.aliyun.vod20170321.models.GetVideoPlayAuthRequest;
import com.aliyun.vod20170321.models.GetVideoPlayAuthResponse;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.FrameGrabber;
import java.util.HashMap;
public class SpdbUtil {
public static Integer getMp4Duration(String url){
double duration = 0;
try (FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(url)) {
frameGrabber.start();
duration = frameGrabber.getLengthInTime()/1000000;
frameGrabber.stop();
} catch (FrameGrabber.Exception e) {
e.printStackTrace();
}
return (int)duration;
};
public static GetVideoPlayAuthResponse getPlayAuth(String vid) throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。