pom.xml

        <!--人脸识别--><dependency><groupId>com.aliyun</groupId><artifactId>aliyun-java-sdk-core</artifactId><version>4.4.8</version></dependency><dependency><groupId>com.aliyun</groupId><artifactId>aliyun-java-sdk-facebody</artifactId><version>1.1.1</version></dependency><!--视频截取--><dependency><groupId>org.bytedeco</groupId><artifactId>javacv-platform</artifactId><version>1.4.4</version></dependency>
  /*** 活体检测* @param fileUrl 照片* @param messge 提示消息* @return*/public Boolean VideoVivoDetection(String fileUrl,String messge){try {Results results = FaceRecognition.VideoVivoDetectionPhoto(fileUrl,messge);Float faceConfidence = Float.valueOf(sysUserRoleMapper.getSysDictItem("活体检测-人脸的置信度"));//置信度 从数据字典表中读取,实现动态调整if(faceConfidence > results.getRate()){throw new BadRequestException(messge + "【人脸的置信度】较低,系统要求置信度为:【" + faceConfidence + "】,本次检查置信度【" + results.getRate() + "】");}return true;}catch (Exception e){throw new BadRequestException(messge + "活体检测识别");}}
package org.jeecg.modules.exam.utils.face;import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.facebody.model.v20191230.*;
import com.aliyuncs.profile.DefaultProfile;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.tzf.BadRequestException;
import org.jeecg.modules.exam.utils.face.entity.Results;
import org.springframework.beans.factory.annotation.Value;import java.util.ArrayList;
import java.util.List;/*** @author :admin* @date :Created in 2020/7/7 17:54* @Time: 17:54* @description:人脸识别* @modified By:* @version: 1.0$*/
@Slf4j
public class FaceRecognition {@Value(value="${face.accessKeyId}")private static String accessKeyId;@Value(value="${face.secret}")private static String secret;/*** 人脸比对* CompareFace可以基于您输入的两张图片,检测两张图片中的人脸,并分别挑选两张图片中的最大人脸进行比较,判断是否为同一人。同时返回这两个人脸的矩形框坐标、比对的置信度,以及不同误识率的置信度阈值。* https://help.aliyun.com/document_detail/151891.html?spm=a2c4g.11186623.6.589.56705de3kX1diD* @param ImageURLA 图片URL地址。当前仅支持上海地域的OSS链接* @param ImageURLB 图片URL地址。当前仅支持上海地域的OSS链接*/public static Confidence FaceThan(String ImageURLA,String ImageURLB) {DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", accessKeyId, secret);IAcsClient client = new DefaultAcsClient(profile);CompareFaceRequest request = new CompareFaceRequest();request.setRegionId("cn-shanghai");request.setImageURLA(ImageURLA);request.setImageURLB(ImageURLB);try {CompareFaceResponse response = client.getAcsResponse(request);Confidence confidence = new Confidence();confidence.copy(response.getData().getConfidence(),response.getData().getRectAList(),response.getData().getRectBList(),response.getData().getThresholds());//System.out.println(new Gson().toJson(response));return confidence;} catch (ServerException e) {e.printStackTrace();} catch (ClientException e) {log.error(e.getMessage());}return null;}/*** 视频活体检测* 文档地址 https://help.aliyun.com/document_detail/167847.html?spm=5176.12901015.0.i12901015.2932525cEVM3hb&accounttraceid=50ed0f85458549a3aeed92836ee86a3fcdfe* @param VideoUrl*/public static Elements VideoVivoDetection(String VideoUrl) {DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", accessKeyId, secret);IAcsClient client = new DefaultAcsClient(profile);DetectVideoLivingFaceRequest request = new DetectVideoLivingFaceRequest();request.setRegionId("cn-shanghai");request.setVideoUrl(VideoUrl);try {DetectVideoLivingFaceResponse response = client.getAcsResponse(request);// System.out.println(response.getData().getElements().toString());Elements elements = new Elements();elements.copy(response.getData().getElements().get(0).getFaceConfidence(),response.getData().getElements().get(0).getLiveConfidence(),response.getData().getElements().get(0).getRect());// System.out.println(new Gson().toJson(response));return elements;} catch (ServerException e) {e.printStackTrace();} catch (ClientException e) {log.error(e.getMessage());
//            System.out.println("ErrCode:" + e.getErrCode());
//            System.out.println("ErrMsg:" + e.getErrMsg());
//            System.out.println("RequestId:" + e.getRequestId());}return null;}/*** 照片活体检测* 文档地址 https://help.aliyun.com/document_detail/155006.html?spm=a2c4g.11186623.6.587.75876c6cq8RdaW* @param PhotoUrl 照片地址* @param messge 提示消息* @return*/public static Results VideoVivoDetectionPhoto(String PhotoUrl,String messge) {DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", accessKeyId, secret);IAcsClient client = new DefaultAcsClient(profile);DetectLivingFaceRequest request = new DetectLivingFaceRequest();request.setRegionId("cn-shanghai");List<DetectLivingFaceRequest.Tasks> tasksList = new ArrayList<DetectLivingFaceRequest.Tasks>();DetectLivingFaceRequest.Tasks tasks1 = new DetectLivingFaceRequest.Tasks();tasks1.setImageURL(PhotoUrl);tasksList.add(tasks1);request.setTaskss(tasksList);try {DetectLivingFaceResponse response = client.getAcsResponse(request);Results results = new Results();results.copy(response.getData().getElements().get(0).getResults().get(0).getLabel(),response.getData().getElements().get(0).getResults().get(0).getRate(),response.getData().getElements().get(0).getResults().get(0).getSuggestion());if("liveness".equals(results.getLabel())){throw new BadRequestException(messge + "请勿上传翻拍照片");}if("review".equals(results.getSuggestion())){throw new BadRequestException(messge + "照片可能来自翻拍,请重新上传");}if("block".equals(results.getSuggestion())){throw new BadRequestException(messge + "照片大概率来自翻拍,请重新上传");}return results;} catch (ServerException e) {e.printStackTrace();log.error("服务器异常 {}" + e.getMessage());} catch (ClientException e) {//客户端异常e.printStackTrace();log.error("客户端异常 异常信息{} ErrCode {} \nErrMsg{} \n RequestId{}" , e.getMessage(), e.getErrCode(), e.getErrMsg(), e.getRequestId());} catch (BadRequestException e) {log.error("自定义异常");return null;}return null;}/*** 地址转换* @param URL*/public static String AddressTranslation(String URL) {//String file = /home/admin/file/1.jpg  或者本地上传//String file = "https://fuss10.elemecdn.com/5/32/c17416d77817f2507d7fbdf15ef22jpeg.jpeg";try {FileUtils fileUtils = FileUtils.getInstance(accessKeyId,secret);String ossurl = fileUtils.upload(URL);System.out.println(ossurl);return ossurl;}catch (ClientException e){System.out.println(e.getMessage());}catch (IOException e){System.out.println(e.getMessage());}return null;}}
package org.jeecg.modules.exam.utils.face;import cn.hutool.core.io.FileUtil;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.FrameGrabber;
import org.bytedeco.javacv.Java2DFrameConverter;
import org.springframework.util.ResourceUtils;import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;/*** @author :admin* @date :Created in 2020/7/9 11:28* @Time: 11:28* @description:视频截取* @modified By:* @version: 1.0$*/
public class VideoCapture {
//    public static void main(String[] args) {
//        String videoPath = "C:\\Users\\admin\\Pictures\\rz\\hz.mp4";
//
//        /**
//         * 1.活体检测
//         * 2.视频截取
//         * 3.相似度认证
//         */
//        Elements elements = FaceRecognition.VideoVivoDetection(videoPath);
//        System.out.println("人脸的置信度--------------" + elements.getFaceConfidence());
//        System.out.println("活体的置信度--------------" + elements.getLiveConfidence());
//        System.out.println("检测出的人脸位置--------------" + elements.getRect());
//        System.out.println("------------------------------活体检测通过");
//        System.out.println("------------------------------活体检测通过");
//        File video = null;
//        try {
//            video = ResourceUtils.getFile(videoPath);
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
//        for (int i = 0; i < 50; i++) {
//            String picPath = "C:\\Users\\admin\\Pictures\\rz\\"+ i +".jpg";
//            getVideoPic(video, picPath,i*10);
//        }
//        long duration = getVideoDuration(video);
//        System.out.println("\n\n\n\n\n\nvideoDuration ************************************** " + duration);
//        System.out.println("\n\n\n\n\n\nvideoDuration ************************************** " + duration);
//        System.out.println("------------------------------视频截取完成");
//        String picPath = "C:\\Users\\admin\\Pictures\\rz\\20200709115814.png";
//        for (int i = 0; i < 1; i++) {
//            String picPath1 = "C:\\Users\\admin\\Pictures\\rz\\"+ i +".jpg";
//            System.out.println("------------------------------对比地址1【" + picPath1 + "】\n【" + picPath + "】");
//            FaceRecognition.FaceThan(picPath1,picPath);
//        }
//        System.out.println("------------------------------相似度认证通过");
//
//
//
//    }/*** 截取视频获得指定帧的图片** @param video  源视频文件* @param picPath 截图存放路径*/public static void getVideoPic(File video, String picPath,int i) {FFmpegFrameGrabber ff = new FFmpegFrameGrabber(video);try {ff.start();// 截取中间帧图片(具体依实际情况而定)// int i = 0;int length = ff.getLengthInFrames();int middleFrame = length / 2;Frame frame = null;while (i < length) {frame = ff.grabFrame();if ((i > middleFrame) && (frame.image != null)) {break;}i++;}// 截取的帧图片Java2DFrameConverter converter = new Java2DFrameConverter();BufferedImage srcImage = converter.getBufferedImage(frame);int srcImageWidth = srcImage.getWidth();int srcImageHeight = srcImage.getHeight();// 对截图进行等比例缩放(缩略图)int width = 480;int height = (int) (((double) width / srcImageWidth) * srcImageHeight);BufferedImage thumbnailImage = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);thumbnailImage.getGraphics().drawImage(srcImage.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, 0, null);File picFile = new File(picPath);ImageIO.write(thumbnailImage, "jpg", picFile);ff.stop();//删除临时文件FileUtil.del(picFile);} catch (IOException e) {e.printStackTrace();}}/*** 获取视频时长,单位为秒* @param video 源视频文件* @return 时长(s)*/public static long getVideoDuration(File video) {long duration = 0L;FFmpegFrameGrabber ff = new FFmpegFrameGrabber(video);try {ff.start();duration = ff.getLengthInTime() / (1000 * 1000);ff.stop();} catch (FrameGrabber.Exception e) {e.printStackTrace();}return duration;}/**** 截取视频获得指定帧的图片     ** @param video  源视频文件* @param picPath 截图存放路径* @param i 帧*/public static String getVideoPic(File video, String picPath,int i) {FFmpegFrameGrabber ff = new FFmpegFrameGrabber(video);try {ff.start();// 截取中间帧图片(具体依实际情况而定)// int i = 0;int length = ff.getLengthInFrames();int middleFrame = length / 2;Frame frame = null;while (i < length) {frame = ff.grabFrame();if ((i > middleFrame) && (frame.image != null)) {break;}i++;}// 截取的帧图片Java2DFrameConverter converter = new Java2DFrameConverter();BufferedImage srcImage = converter.getBufferedImage(frame);int srcImageWidth = srcImage.getWidth();int srcImageHeight = srcImage.getHeight();// 对截图进行等比例缩放(缩略图)int width = 480;int height = (int) (((double) width / srcImageWidth) * srcImageHeight);BufferedImage thumbnailImage = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);thumbnailImage.getGraphics().drawImage(srcImage.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, 0, null);File picFile = new File( "/tang/file/upFiles/"+ picPath + "/" + StringUtils.UUIDNanoTime() + ".jpg");if (!picFile.exists()) {picFile.mkdirs();}//File picFile = new File(LinuxUpload + "\\"+ picPath + "\\" + StringUtils.UUIDNanoTime() + ".jpg");ImageIO.write(thumbnailImage, "jpg", picFile);ff.stop();String OssUrl = getOssUrl(picFile,picPath);//阿里云地址//删除临时文件FileUtil.del(picFile);return OssUrl;} catch (IOException e) {e.printStackTrace();log.info("视频截取异常" + e.getMessage());}catch (Exception e) {e.printStackTrace();log.info("视频截取上传异常" + e.getMessage());}return null;}
}

视频处理

依赖

<!-- aliyun oss -->
<dependency><groupId>com.aliyun.oss</groupId><artifactId>aliyun-sdk-oss</artifactId><version>3.6.0</version>
</dependency>

https://www.alibabacloud.com/help/zh/doc-detail/44297.htm

package org.jeecg.modules.exam.controller;import com.aliyun.oss.model.LiveChannelInfo;
import com.aliyun.oss.model.LiveChannelListing;
import com.aliyun.oss.model.LiveRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.util.tzf.ResponseEntityT;
import org.jeecg.modules.exam.utils.LiveChannelAdd;
import org.jeecg.modules.exam.utils.LiveChannelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;import java.util.List;/*** @author :admin* @date :Created in 2020/9/10 16:43* @Time: 16:43* @description:LiveChannel 工具类* @modified By:* @version: 1.0$*/@Slf4j
@Controller
@RequestMapping("/oss/LiveChannel")
@Api(tags="LiveChannel工具")
public class LiveChannelController {@ResponseBody@GetMapping("/createLiveChannel")@ApiOperation(value="创建 LiveChannel", notes="")public ResponseEntityT<LiveChannelAdd> createLiveChannel(@RequestParam(name = "liveChannelName") String liveChannelName) {return ResponseEntityT.ok(LiveChannelUtils.createLiveChannel(liveChannelName));}@ResponseBody@GetMapping("/listLiveChannels")@ApiOperation(value="列举 LiveChannel", notes="")public ResponseEntityT<LiveChannelListing> listLiveChannels() {return ResponseEntityT.ok(LiveChannelUtils.listLiveChannels());}//    @ResponseBody
//    @GetMapping("/deleteLiveChannel")
//    @ApiOperation(value="删除 LiveChannel", notes="")
//    public ResponseEntityT deleteLiveChannel(@RequestParam(name = "liveChannelName") String liveChannelName) {
//        LiveChannelUtils.deleteLiveChannel(liveChannelName);
//        return ResponseEntityT.ok();
//    }@ResponseBody@GetMapping("/setLiveChannelStatus")@ApiOperation(value="设置 LiveChannel 状态", notes=" stu 二种状态 enabled disabled ")public ResponseEntityT setLiveChannelStatus(@RequestParam(name = "liveChannelName") String liveChannelName, String stu) {LiveChannelUtils.setLiveChannelStatus(liveChannelName,stu);return ResponseEntityT.ok("操作成功");}@ResponseBody@GetMapping("/getLiveChannelInfo")@ApiOperation(value="获取 LiveChannel 配置信息")public ResponseEntityT<LiveChannelInfo> getLiveChannelInfo(@RequestParam(name = "liveChannelName") String liveChannelName) {return ResponseEntityT.ok(LiveChannelUtils.getLiveChannelInfo(liveChannelName));}@ResponseBody@GetMapping("/postVodPlaylist")@ApiOperation(value="生成 LiveChannel 播放列表")public ResponseEntityT<?> getLiveChannelInfo(@RequestParam(name = "liveChannelName") String liveChannelName, String playListName, String start, String end) {LiveChannelUtils.postVodPlaylist(liveChannelName,playListName, start, end);return ResponseEntityT.ok("生成成功");}@ResponseBody@GetMapping("/getVodPlaylist")@ApiOperation(value=" 查看 LiveChannel 播放列表")public ResponseEntityT<?> getVodPlaylist(@RequestParam(name = "liveChannelName") String liveChannelName, String start, String end) {LiveChannelUtils.getVodPlaylist(liveChannelName, start, end);return ResponseEntityT.ok("生成成功");}@ResponseBody@GetMapping("/getLiveChannelHistory")@ApiOperation(value=" 获取 LiveChannel 推流记录")public ResponseEntityT<List<LiveRecord>> getLiveChannelHistory(@RequestParam(name = "liveChannelName") String liveChannelName) {return ResponseEntityT.ok(LiveChannelUtils.getLiveChannelHistory(liveChannelName));}}
package org.jeecg.modules.exam.utils;import com.alibaba.fastjson.JSON;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.*;
import org.jeecg.common.util.tzf.BadRequestException;import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;/*** @author :admin* @date :Created in 2020/9/10 15:48* @Time: 15:48* @description:* @modified By:* @version: $*/
public class LiveChannelUtils {private static String endpoint = "oss-cn-shanghai.aliyuncs.com";//用shanghai的private static String accessKeyId = "XXXXXXXXXXXXXXXXXXXX";private static String accessKeySecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";private static String bucketName = "XXXXX-video";/*** 创建 LiveChannel*/public static LiveChannelAdd createLiveChannel(String liveChannelName) {LiveChannelAdd liveChannelAdds = new LiveChannelAdd();// 创建 OSSClient 实例。OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);CreateLiveChannelRequest request = new CreateLiveChannelRequest(bucketName,liveChannelName, "desc", LiveChannelStatus.Enabled, new LiveChannelTarget());CreateLiveChannelResult result = oss.createLiveChannel(request);//        //获取推流地址
//        List<String> publishUrls = result.getPublishUrls();
//        for (String item : publishUrls) {
//            publishUrl.add(item);System.out.println("获取推流地址------------------------------");System.out.println(item);
//        }
//        //获取播放地址。
//        List<String> playUrls = result.getPlayUrls();
//        for (String item : playUrls) {
//            playUrl.add(item);System.out.println("获取播放地址------------------------------");System.out.println(item);
//        }liveChannelAdds.setPublishUrls(result.getPublishUrls());liveChannelAdds.setPlayUrls(result.getPlayUrls());oss.shutdown();return liveChannelAdds;}/*** 列举 LiveChannel*/public static LiveChannelListing listLiveChannels() {// 创建 OSSClient 实例。OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);ListLiveChannelsRequest request = new ListLiveChannelsRequest(bucketName);LiveChannelListing liveChannelListing = oss.listLiveChannels(request);System.out.println("列举 LiveChannel------------------------------");System.out.println(JSON.toJSONString(liveChannelListing));oss.shutdown();return liveChannelListing;}//    /**
//     * 删除 LiveChannel
//     */
//    public static void deleteLiveChannel(String liveChannelName) {
//        // 创建 OSSClient 实例。
//        OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
//        LiveChannelGenericRequest request = new LiveChannelGenericRequest(bucketName, liveChannelName);
//        try {
//            oss.deleteLiveChannel(request);
//        } catch (OSSException ex) {
//            ex.printStackTrace();
//            throw new BadRequestException("推流通道关闭失败," + ex.getMessage());
//        } catch (ClientException ex) {
//            ex.printStackTrace();
//            throw new BadRequestException("推流通道关闭失败," + ex.getMessage());
//        } finally {
//            oss.shutdown();
//        }
//    }/*** 设置 LiveChannel 状态*/public static void setLiveChannelStatus(String liveChannelName,String stu) {//String liveChannelName = "<yourLiveChannelName>";// 创建OSSClient实例。OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);try {if("enabled".equals(stu)){oss.setLiveChannelStatus(bucketName, liveChannelName, LiveChannelStatus.Enabled );}if("disabled".equals(stu)){oss.setLiveChannelStatus(bucketName, liveChannelName, LiveChannelStatus.Disabled );}} catch (OSSException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));throw new BadRequestException(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} catch (ClientException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));throw new BadRequestException(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} finally {oss.shutdown();}}/*** 获取 LiveChannel 配置信息*/public static LiveChannelInfo getLiveChannelInfo(String liveChannelName) {//String liveChannelName = "<yourLiveChannelName>";// 创建 OSSClient 实例。OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);LiveChannelInfo liveChannelInfo = oss.getLiveChannelInfo(bucketName, liveChannelName);System.out.println(JSON.toJSONString(liveChannelInfo));oss.shutdown();return liveChannelInfo;}/*** 生成 LiveChannel 播放列表* @param liveChannelName* @param playListName* @param start* @param end*/public static void postVodPlaylist(String liveChannelName,String playListName,String start,String end) {// 创建 OSSClient 实例。OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);long startTime = getUnixTimestamp(start);//"2019-06-27 23:00:00"long endTIme = getUnixTimestamp(end);//"2019-06-28 23:00:00"try {oss.generateVodPlaylist(bucketName, liveChannelName, playListName, startTime, endTIme);} catch (OSSException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));throw new BadRequestException(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} catch (ClientException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));throw new BadRequestException(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} finally {oss.shutdown();}}public static void postVodPlaylistT(String liveChannelName,String playListName,String start,String end) {// 创建 OSSClient 实例。OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);long startTime = getUnixTimestamp(start);//"2019-06-27 23:00:00"long endTIme = getUnixTimestamp(end);//"2019-06-28 23:00:00"try {oss.generateVodPlaylist(bucketName, liveChannelName, playListName, startTime, endTIme);} catch (OSSException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} catch (ClientException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} finally {oss.shutdown();}}/*** 生成 LiveChannel 播放列表* @param liveChannelName* @param playListName* @param startTime* @param endTIme*/public static void postVodPlaylist(String liveChannelName,String playListName,long startTime,long endTIme) {// 创建 OSSClient 实例。OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);try {oss.generateVodPlaylist(bucketName, liveChannelName, playListName, startTime, endTIme);} catch (OSSException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));throw new BadRequestException(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} catch (ClientException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));throw new BadRequestException(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} finally {oss.shutdown();}}private static long getUnixTimestamp(String time) {DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");try {Date date = format.parse(time);return date.getTime() / 1000;} catch (ParseException e) {e.printStackTrace();return 0;}}/*** 查看 LiveChannel 播放列表* @param liveChannelName* @param start* @param end*/public static void getVodPlaylist(String liveChannelName,String start,String end) {
//        String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
//        // 阿里云主账号 AccessKey 拥有所有 API 的访问权限,风险很高。
//        // 强烈建议您创建并使用 RAM 账号进行 API 访问或日常运维,请登录 https://ram.console.aliyun.com 创建 RAM 账号。
//        String accessKeyId = "<yourAccessKeyId>";
//        String accessKeySecret = "<yourAccessKeySecret>";
//        String liveChannelName = "<yourLiveChannelName>";
//        String bucketName = "<yourBucketName>";// 创建 OSSClient 实例。OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);long startTime = getUnixTimestamp(start);//"2019-06-27 23:00:00"long endTIme = getUnixTimestamp(end);//"2019-06-28 23:00:00"try {OSSObject ossObject = oss.getVodPlaylist(bucketName, liveChannelName, startTime, endTIme);System.out.println(ossObject.toString());} catch (OSSException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));throw new BadRequestException(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} catch (ClientException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));throw new BadRequestException(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} finally {oss.shutdown();}}/*** 获取 LiveChannel 推流记录*/public static List<LiveRecord> getLiveChannelHistory(String liveChannelName) {try {OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);List<LiveRecord> list = oss.getLiveChannelHistory(bucketName, liveChannelName);System.out.println("-----推流记录-----");System.out.println(JSON.toJSONString(list));System.out.println("-----推流记录-----");oss.shutdown();return list;}catch (Exception e){throw new BadRequestException("获取异常-" + e.getMessage());}}public static void main(String[] args) {//getLiveChannelHistory("online_examination");long s = Long.valueOf("1599793969310");long e = Long.valueOf("1599793986570");LiveChannelAdd liveChannelAdd = createLiveChannel("online-examination");System.out.println(liveChannelAdd.getPlayUrls());System.out.println(liveChannelAdd.getPublishUrls());//listLiveChannels();
//        postVodPlaylist("online_examination","playlist.m3u8","2020-09-10 20:44:59","2020-09-11 15:45:17");//getLiveChannelHistory("online-examination");
//        listLiveChannels();}/*** 生成 LiveChannel 播放列表* @param liveChannelName*/public static void postVodPlaylist(String liveChannelName) {//String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";// 阿里云主账号 AccessKey 拥有所有 API 的访问权限,风险很高。// 强烈建议您创建并使用 RAM 账号进行 API 访问或日常运维,请登录 https://ram.console.aliyun.com 创建 RAM 账号。
//        String accessKeyId = "<yourAccessKeyId>";
//        String accessKeySecret = "<yourAccessKeySecret>";
//        String liveChannelName = "<yourLiveChannelName>";
//        String bucketName = "<yourBucketName>";String playListName = "playlist.m3u8";// 创建 OSSClient 实例。OSS oss = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);long startTime = getUnixTimestamp("2020-09-10 23:00:00");//long endTIme = getUnixTimestamp("2020-09-11 23:00:00");//try {oss.generateVodPlaylist(bucketName, liveChannelName, playListName, startTime, endTIme);} catch (OSSException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));throw new BadRequestException(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} catch (ClientException ex) {System.out.println(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));throw new BadRequestException(ex.getErrorCode().concat(",").concat(ex.getErrorMessage()));} finally {oss.shutdown();}}
}

前端uni-app推流调用

人脸识别(基于阿里云)相关推荐

  1. 天源迪科与阿里云发布联合解决方案,基于阿里云原生产品打造卓越的数字化采购平台

    天源迪科成立成立于1993年,二十多年来深耕电信运营商业务运营支撑软件和服务,并在此基础上持续投入研发,紧抓行业发展需求,大力发展云计算.大数据.人工智能.物联网等先进技术,实现业务领域向安全.政府. ...

  2. 基于阿里云搭建的适合初创企业的轻量级架构--架构总结

    ----基于阿里云搭建的适合初创企业的轻量级架构 前言 在项目的初期往往存在很多变数,业务逻辑时刻在变,而且还要保证快速及时,所以,一个灵活多变.快速部署.持续集成并可以适应多种情况的架构便显得尤为重 ...

  3. 如何基于阿里云搭建适合初创企业的轻量级架构?

    ----基于阿里云搭建的适合初创企业的轻量级架构 前言 在项目的初期往往存在很多变数,业务逻辑时刻在变,而且还要保证快速及时,所以,一个灵活多变.快速部署.持续集成并可以适应多种情况的架构便显得尤为重 ...

  4. 基于阿里云数加MaxCompute的企业大数据仓库架构建设思路

    摘要: 数加大数据直播系列课程主要以基于阿里云数加MaxCompute的企业大数据仓库架构建设思路为主题分享阿里巴巴的大数据是怎么演变以及怎样利用大数据技术构建企业级大数据平台. 本次分享嘉宾是来自阿 ...

  5. 高德地图基于阿里云MaxCompute的最佳实践

    原文链接:点击打开链接 摘要: 云计算带来的变革不言而喻,作为一种新型的IT交付模式,切实为企业节省IT成本.加快IT与企业业务结合效率.提升创新能力.加强管理水平以及增强系统本身的可靠性等方面提供巨 ...

  6. stio简介及基于阿里云ACK安装Istio

    Istio就是Service Mesh的落地实现. ​ 1. Istio的功能 负载均衡,服务发现 故障恢复,指标收集和监控 A/B测试,灰度发布 限流,访问控制和端到端认证 2. Istio的架构 ...

  7. 安全态势_交互发现 —— 基于阿里云轻松搭建安全大屏

    原文链接 摘要: 使用DataV大屏展现态势感知 DNS 会话日志,从而实现交互式安全威胁发现. 2017年,阿里云启动MVP(Most Valuable Professional)项目.顾名思义,M ...

  8. 安全态势,交互发现 —— 基于阿里云轻松搭建安全大屏

    摘要:使用DataV大屏展现态势感知 DNS 会话日志,从而实现交互式安全威胁发现. 2017年,阿里云启动MVP(Most Valuable Professional)项目.顾名思义,MVP正在寻找 ...

  9. 基于阿里云实现3D模型显示(WebAR项目)

    基于阿里云实现webar中3D模型的展示 WebAR介绍 demo 网页端html 阿里云服务器配置 WebAR介绍 这个项目是帮朋友做的毕设-原本是四月份就打算写这篇文章的,但是由于各种原因推到了六 ...

  10. 基于阿里云用C/C++做了一个http协议与TCP协议的web聊天室的服务器——《干饭聊天室》

    基于阿里云用C/C++做了一个http协议与TCP协议的web聊天室的服务器--<干饭聊天室> 在这里首先感谢前端小伙伴飞鸟 前端技术请看一款基于React.C++,使用TCP/HTTP协 ...

最新文章

  1. Activity中KeyEvent的传递
  2. 【AI白身境】只会用Python?g++,CMake和Makefile了解一下​​​​​​​
  3. NYOJ-523 亡命逃窜(三维立体的BFS)
  4. Jenkins+ant+Jenkins接口持续集成测试配置
  5. 领域驱动设计-从贫血模型到充血模型
  6. 创建vue项目(四)路由相关知识、路由守卫、插槽、打包小细节
  7. HashMap 排序
  8. java在线学习系统源码_java学习成长之路(基础,源码,项目,实战)
  9. 《搭建Centos7之一》
  10. 拓端tecdat|R语言使用Metropolis- Hasting抽样算法进行逻辑回归
  11. yui compressor php,php 使用 yui compressor 压缩或批量压缩 js和css文件的类
  12. js原型继承的几种方式
  13. TinyGPS使用说明
  14. springboot 解决java.lang.ArrayStoreException
  15. Android 10.0 Launcher3双层(抽屉)高斯模糊(毛玻璃)背景功能的实现
  16. 梦想在三十岁起航!__来自黑马程序员69期安卓班的学员
  17. Linux 删除文件实现回收站功能
  18. 2008 IT图书大盘点
  19. 怎么释放C盘空间?清理C盘空间的4大方法分享!
  20. 技术管理实战笔记-角色认知篇

热门文章

  1. 语音合成论文优选:唇语Speaker disentanglement in video-to-speech conversion
  2. 图片自动排版php,少为人知的Word自动排版:3秒将1000张图片对齐、固定尺寸
  3. 《一个大学生的学习笔记》
  4. 如何解决Chrome首页被流氓网站劫持的问题
  5. webpack项目css插件压缩等步骤
  6. c编程语言英文读不懂,C语言编程 可以不会英语 但必须要懂以下英语单词
  7. kali wifi不可用_Kali Linux系统解决无线网卡无驱动问题教程:
  8. 开源工作流引擎(含流程设计器)
  9. 大数据分析策略和发展趋势
  10. 三.开发记录之移动硬盘装ubuntu系统的配置、环境、各类软件安装和备份等