91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 40.99MB
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發布日期: 2023-07-10
  • 語言: Java
  • 標簽:

資源簡介

壓縮包里面工具和代碼可以壓縮人臉識別的視頻之后給百度和騰訊接口識別出結果,減少視頻傳輸時間并不影響識別結果。

資源截圖

代碼片段和文件信息

package?com.face.test;

import?org.springframework.web.multipart.MultipartFile;

import?java.io.ByteArrayOutputStream;
import?java.io.File;
import?java.io.FileInputStream;
import?java.io.FileNotFoundException;
import?java.util.ArrayList;
import?java.util.List;

public?class?FFmpegUtil?{

/**
?*?
?*?@param?ffmpegPath?ffmpeg壓縮工具路徑
?*?@param?faceVideo?上傳的視頻
?*?@return
?*/
????public?static?byte[]?FFmpeg(String?ffmpegPath?MultipartFile?faceVideo){

????????byte[]?byteVideo?=?null;
????????File?oldFile?=?null?newFile?=?null;
????????try?{
????????????String?suffix?=?“mp4“;
????????????String?fileName?=?faceVideo.getOriginalFilename();
????????????int?index?=?fileName.lastIndexOf(“.“);
????????????if(index?>?0)?{
????????????????suffix?=?fileName.substring(index);
????????????}
????????????oldFile?=?File.createTempFile(“oldVideo“?suffix);
????????????faceVideo.transferTo(oldFile);

????????????if?(!oldFile.isFile())?{
????????????????return?byteVideo;
????????????}

????????????String?inputPath?=?oldFile.getPath();
????????????newFile?=?File.createTempFile(“newVideo“?suffix);
????????????String?outputPath?=?newFile.getPath();
????????????int?type?=?checkContentType(inputPath);
????????????List?command?=?getFFmpegCommand(type?ffmpegPath?inputPath?outputPath);
????????????if?(command.size()?>?0)?{
????????????????boolean?result?=?process(command);
????????????????if(result)?{
????????????????????byteVideo?=?getBytes(outputPath);
????????????????}
????????????}
????????}
????????catch?(Exception?e){
????????????e.printStackTrace();
????????}
????????finally?{
????????????if(oldFile?!=?null)?{
????????????????oldFile.deleteOnExit();
????????????}
????????????if(newFile?!=?null)?{
????????????????newFile.deleteOnExit();
????????????}
????????}
????????return?byteVideo;
????}

????private?static?int?checkContentType(String?inputPath)?{
????????String?type?=?inputPath.substring(inputPath.lastIndexOf(“.“)?+?1?inputPath.length()).toLowerCase();
????????//?ffmpeg能解析的格式:(asx,asf,mpg,wmv,3gp,mp4,mov,avi,flv等)
????????if?(type.equals(“avi“))?{
????????????return?1;
????????}?else?if?(type.equals(“mpg“))?{
????????????return?1;
????????}?else?if?(type.equals(“wmv“))?{
????????????return?1;
????????}?else?if?(type.equals(“3gp“))?{
????????????return?1;
????????}?else?if?(type.equals(“mov“))?{
????????????return?1;
????????}?else?if?(type.equals(“mp4“))?{
????????????return?1;
????????}?else?if?(type.equals(“mkv“))?{
????????????return?1;
????????}?else?if?(type.equals(“asf“))?{
????????????return?0;
????????}?else?if?(type.equals(“flv“))?{
????????????return?0;
????????}?else?if?(type.equals(“rm“))?{
????????????return?0;
????????}?else?if?(type.equals(“rmvb“))?{
????????????return?1;
????????}
????????return?9;
????}

????private?static?boolean?process(List?command)?throws?Exception?{
????????try?{
????????????Process?videoProcess?=?new?ProcessBuilder(

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????63118848??2018-07-13?09:36??ffmpeg.exe
?????文件????????6714??2018-08-15?09:59??FFmpegUtil.java
?????文件????63971848??2018-07-13?09:36??ffmpeg

評論

共有 條評論

相關資源