GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — java-util/HdCommonVideoUtil.java at master · lianyj/java-util Expand file tree/ Copy pathHdCommonVideoUtil.javaMore file actions 116 lines (99 loc) · 3.07 KB / Copy pathHdCommonVideoUtil.javaFile metadata and controls116 lines (99 loc) · 3.07 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 /************************************************************************** * Copyright (c) 2015-2017 Zhejiang TaChao Network Technology Co.,Ltd. * All rights reserved. * * 项目名称:浙江踏潮-汇道体育 * 版权说明:本软件属浙江踏潮网络科技有限公司所有,在未获得浙江踏潮网络科技有限公司正式授权 * 情况下,任何企业和个人,不能获取、阅读、安装、传播本软件涉及的任何受知 * 识产权保护的内容。 ***************************************************************************/ package com.zjtachao.hd.common.util.tools; import java.io.File; import java.io.FileInputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.jswiff.SWFReader; import com.zjtachao.hd.common.video.swf.JPEGListener; import com.zjtachao.hd.common.video.tools.Encoder; import com.zjtachao.hd.common.video.tools.MultimediaInfo; import com.zjtachao.hd.common.video.tools.VideoSize; /** * 视频工具类 * @author <a href="mailto:[email protected]">zhuguofeng</a> * @version $Id$ * @since 2.0 */ public class HdCommonVideoUtil { /** 日志 **/ private static Logger logger = LoggerFactory.getLogger(HdCommonVideoUtil.class); /** * * 获取视频尺寸 * @param path * @return */ public static VideoSize getVideoSize(String path){ File file = new File(path); VideoSize videoSize = null; try { Encoder encoder = new Encoder(); MultimediaInfo info = encoder.getInfo(file); videoSize = info.getVideo().getSize(); }catch(Exception ex){ logger.error("获取视频尺寸失败!" , ex); } return videoSize; } /** * * 获得视频时长 * @param file * @return */ public static long getVideoTimeLength(String path){ long result = -1l; File file = new File(path); Encoder encoder = new Encoder(); try{ MultimediaInfo info = encoder.getInfo(file); if (null != info.getVideo() || null != info.getAudio()) { Long duration = info.getDuration() / 1000; result = duration; } }catch(Exception e){ logger.error("获取视频时长错误!" ,e); } return result; } /** * * 生成缩略图 * @param videoPath */ public static void getFirstFrame(String videoPath){ VideoSize videoSize = getVideoSize(videoPath); try { String imgPath = videoPath.substring(0,videoPath.lastIndexOf("."))+".jpg"; Encoder encoder = new Encoder(); encoder.getFirstFrame(videoPath, imgPath, videoSize.getWidth(), videoSize.getHeight()); }catch(Exception ex){ logger.error("生成缩略图失败!" , ex); } } /** * * 获取swf的第一帧 * @param videoPath */ public static void getSwfFirstFrame(String videoPath){ try{ String imgPath = videoPath.substring(0,videoPath.lastIndexOf("."))+".jpg"; File sourceFile = new File(videoPath); SWFReader reader = new SWFReader(new FileInputStream(sourceFile)); reader.addListener(new JPEGListener(imgPath)); reader.read(); }catch(Exception ex){ logger.error("生成swf缩略图失败!" , ex); } } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |