suntianwu 3 年之前
父节点
当前提交
a4c457fa25
共有 3 个文件被更改,包括 53 次插入7 次删除
  1. 5 1
      pom.xml
  2. 8 6
      src/main/java/com/iden/bms/service/SysUserService.java
  3. 40 0
      src/main/java/com/iden/common/util/VideoUtil.java

+ 5 - 1
pom.xml

@@ -283,7 +283,11 @@
             <artifactId>ffmpeg-platform</artifactId>
             <artifactId>ffmpeg-platform</artifactId>
             <version>3.4.2-1.4.1</version>
             <version>3.4.2-1.4.1</version>
         </dependency>
         </dependency>
-
+        <dependency>
+            <groupId>net.bramp.ffmpeg</groupId>
+            <artifactId>ffmpeg</artifactId>
+            <version>0.6.2</version>
+        </dependency>
     </dependencies>
     </dependencies>
 
 
     <build>
     <build>

+ 8 - 6
src/main/java/com/iden/bms/service/SysUserService.java

@@ -58,14 +58,16 @@ public class SysUserService {
 
 
     public UserLoginedConvertVO getLoginUser(String username, String password, String securityCode, HttpServletRequest request) throws BDException {
     public UserLoginedConvertVO getLoginUser(String username, String password, String securityCode, HttpServletRequest request) throws BDException {
 
 
-        if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password) || StringUtils.isEmpty(securityCode)) {
+//        if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password) || StringUtils.isEmpty(securityCode)) {
+//            throw new BDException("登录参数不能为空");
+//        }
+        if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password) ) {
             throw new BDException("登录参数不能为空");
             throw new BDException("登录参数不能为空");
         }
         }
-
-        String securityCodeRedis = (String)redisUtil.hget(RedisKeyConstant.LOGIN_VALIDATE_CODE,username);
-        if (!securityCode.equalsIgnoreCase(securityCodeRedis)){
-            throw new BDException("验证码不正确");
-        }
+//        String securityCodeRedis = (String)redisUtil.hget(RedisKeyConstant.LOGIN_VALIDATE_CODE,username);
+//        if (!securityCode.equalsIgnoreCase(securityCodeRedis)){
+//            throw new BDException("验证码不正确");
+//        }
 
 
         UserLoginedConvertVO userLoginedConvertVO = null;
         UserLoginedConvertVO userLoginedConvertVO = null;
 
 

+ 40 - 0
src/main/java/com/iden/common/util/VideoUtil.java

@@ -2,6 +2,10 @@ package com.iden.common.util;
 
 
 
 
 import com.iden.common.enums.TimeoutOption;
 import com.iden.common.enums.TimeoutOption;
+import net.bramp.ffmpeg.FFmpeg;
+import net.bramp.ffmpeg.FFmpegExecutor;
+import net.bramp.ffmpeg.FFprobe;
+import net.bramp.ffmpeg.builder.FFmpegBuilder;
 import org.bytedeco.javacpp.avcodec;
 import org.bytedeco.javacpp.avcodec;
 import org.bytedeco.javacv.*;
 import org.bytedeco.javacv.*;
 import org.bytedeco.javacv.Frame;
 import org.bytedeco.javacv.Frame;
@@ -288,6 +292,42 @@ public class VideoUtil {
         grabber.stop();
         grabber.stop();
         grabber.release();
         grabber.release();
     }
     }
+
+    public void cut3() throws Exception{
+        FFmpeg ffmpeg = new FFmpeg("/path/to/ffmpeg");
+        FFprobe ffprobe = new FFprobe("/path/to/ffprobe");
+
+        FFmpegBuilder builder = new FFmpegBuilder()
+
+                .setInput("input.mp4")     // Filename, or a FFmpegProbeResult
+                .overrideOutputFiles(true) // Override the output if it exists
+
+                .addOutput("output.mp4")   // Filename for the destination
+                .setFormat("mp4")        // Format is inferred from filename, or can be set
+                .setTargetSize(250_000)  // Aim for a 250KB file
+
+                .disableSubtitle()       // No subtiles
+
+                .setAudioChannels(1)         // Mono audio
+                .setAudioCodec("aac")        // using the aac codec
+                .setAudioSampleRate(48_000)  // at 48KHz
+                .setAudioBitRate(32768)      // at 32 kbit/s
+
+                .setVideoCodec("libx264")     // Video using x264
+                .setVideoFrameRate(24, 1)     // at 24 frames per second
+                .setVideoResolution(640, 480) // at 640x480 resolution
+
+                .setStrict(FFmpegBuilder.Strict.EXPERIMENTAL) // Allow FFmpeg to use experimental specs
+                .done();
+
+        FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
+
+// Run a one-pass encode
+        executor.createJob(builder).run();
+
+// Or run a two-pass encode (which is better quality at the cost of being slower)
+        executor.createTwoPassJob(builder).run();
+    }
     public static void main(String[] args) {
     public static void main(String[] args) {
         try {
         try {
             //getList(10,113);
             //getList(10,113);