当前位置: 首页 > news >正文

登录官方网站永川网站建设公司

登录官方网站,永川网站建设公司,黔东南网站建设,wordpress版本信息在哪里查看java 实现视频转换通用工具类#xff1a;视频相互转换-Ffmpeg(三)说明#xff1a;视频加水印支持右上角、左上角、左下角、右下角、底部居中几个方位1.根据水印文字---添加视频水印/*** 根据水印文字---添加视频水印* param srcPath 原视频路径* param tarVideoPath 生成后的…java 实现视频转换通用工具类视频相互转换-Ffmpeg(三)说明视频加水印支持右上角、左上角、左下角、右下角、底部居中几个方位1.根据水印文字---添加视频水印/*** 根据水印文字---添加视频水印* param srcPath 原视频路径* param tarVideoPath 生成后的视频路径* param wmPosition 水印位子* param alpha 透明度* param txt String 文字* param fontSize 每个字的宽度和高度是一样的* param fontColor Color 字体颜色* param isBold 字体是否加粗* param fontType 字体样式* param fontPath 字体文件* return*/public static boolean processFfmpegWatermkByFont(String srcPath,String tarVideoPath,int wmPosition, float alpha,String txt, int fontSize,Color fontColor,boolean isBold,String fontType,String fontPath) {//通过文字生成的图片临时路径String waterMarkPath WebAppUtils.getWebAppRoot() BaseCommonUtil.TXTIMGPATH BaseCommonUtil.getDateNum() .png;//waterMarkPath D:/project/BSRCM_TRUNK/WebRoot/swf/txtImg/1.png;//通过文字生成透明图片ImageHelps.createJpgByFont(txt,fontSize,fontColor,isBold,fontType,fontPath,waterMarkPath);//avs ---通过水印图片添加水印视频//return processFfmpegWatermarkByImage(srcPath,tarVideoPath,waterMarkPath,wmPosition,alpha);//vfilters ---通过水印图片添加水印视频boolean boo processFfmpegWatermarkByImg(srcPath,tarVideoPath,waterMarkPath,wmPosition,alpha);if(boo){logger.info(【 srcPath 】 视频添加文字水印图片成功! );return true;}else{logger.error(【 srcPath 】 processFfmpegWatermkByFont 视频添加文字水印图片失败! );return false;}}2.根据水印图片---添加视频水印/***根据水印图片---添加视频水印* param srcPath 原视频路径* param tarVideoPath 生成后的视频路径* param waterMarkPath 水印图片路径* param wmPosition 水印位子* param alpha 透明度* return*/public static boolean processFfmpegWatermarkByImg(String srcPath,String tarVideoPath,String waterMarkPath,int wmPosition, float alpha) {if (!checkfile(srcPath)) {logger.error(【 srcPath 】 不存在 !);return false;}if (!checkfile(waterMarkPath)) {logger.error(【 waterMarkPath 】 不存在 !);return false;}//如果父目录不存在就创建一个tarVideoPath BaseCommonUtil.replaceFliePathStr(tarVideoPath);BaseCommonUtil.mkdir(tarVideoPath);//缩放图片zooImage(srcPath, waterMarkPath);//要执行的shell脚本路径String shellPath WebappConfigUtil.getParameter(shellPath);if (!checkfile(shellPath)) {logger.error(【 shellPath 】shell脚本路径 不存在 !);}String extendTarName tarVideoPath.substring(tarVideoPath.lastIndexOf(.)1,tarVideoPath.length());Process process null;try {String os System.getProperty(os.name);if (os ! null os.toLowerCase().startsWith(windows)) {String picPath waterMarkPath.substring(waterMarkPath.indexOf(WebRoot),waterMarkPath.lastIndexOf(/));waterMarkPath waterMarkPath.substring(waterMarkPath.lastIndexOf(/)1,waterMarkPath.length());process Runtime.getRuntime().exec(shellPath picPath ffmpegPath srcPath waterMarkPath getVideoPosition(wmPosition) tarVideoPath);} else{process Runtime.getRuntime().exec(shellPath ffmpegPath srcPath waterMarkPath getVideoPosition(wmPosition) tarVideoPath);}doWaitFor(process);//转换mate信息if(MP4.equals(extendTarName.toUpperCase())){return execMp4Box(tarVideoPath);}if (!checkfile(tarVideoPath)) {logger.error(【 srcPath 】processFfmpegWatermarkByImage 视频添加水印不成功 !);return false;}return true;} catch (Exception e) {logger.error(【 srcPath 】processFfmpegWatermarkByImage 视频添加水印不成功 !);return false;}finally{if(process ! null){process.destroy();}}}3.根据方位数字获取值/*** 根据方位数字获取值* param wmPosition* Top left corner* ffmpeg –i inputvideo.avi -vf moviewatermarklogo.png [watermark]; [in][watermark] overlay10:10 [out] outputvideo.flv* Top right corner* ffmpeg –i inputvideo.avi -vf moviewatermarklogo.png [watermark]; [in][watermark] overlaymain_w-overlay_w-10:10 [out] outputvideo.flv* Bottom left corner* ffmpeg –i inputvideo.avi -vf moviewatermarklogo.png [watermark]; [in][watermark] overlay10:main_h-overlay_h-10 [out] outputvideo.flv* Bottom right corner* ffmpeg –i inputvideo.avi -vf moviewatermarklogo.png [watermark]; [in][watermark] overlaymain_w-overlay_w-10:main_h-overlay_h-10 [out] outputvideo.flv* return*/public static String getVideoPosition(int wmPosition){String positionStr main_w-overlay_w-10:main_h-overlay_h-10; //默认右上角switch (wmPosition) {case 0:positionStr 10:10; //左上角break;case 1:positionStr main_w-overlay_w-10:10; //右上角break;case 2:positionStr 10:main_h-overlay_h-10; //左下角break;case 3:positionStr main_w-overlay_w-10:main_h-overlay_h-10; //右下角break;case 4:positionStr (main_w-overlay_w)/2:main_h-overlay_h:1; //底部居中break;default:break;}return positionStr;}4.缩放图片/*** 缩放图片* param srcPath 视频路径* param wmImgPath 水印图片路径* return*/public static void zooImage(String srcPath,String wmImgPath){//获取视频信息VideoInfo videoInfo VideoInfoHelps.getVideoInfo(srcPath);int width 0; //视频宽int height 0; //视频高if(videoInfo ! null){String widthStr videoInfo.getWidth(); //宽if(StringUtils.isNotEmpty(widthStr)) width Integer.parseInt(widthStr);String heightStr videoInfo.getHeight(); //高if(StringUtils.isNotEmpty(heightStr)) height Integer.parseInt(heightStr);}if(width !0 || height !0){ //如果获取到视频宽高//进行图片缩放ImageHelps.zoomPerImg(wmImgPath, wmImgPath,width,height);}}5.获取xy坐标值返回String数组/*** 获取xy坐标值返回String数组* param wmPosition* 0:左上角* 1:右上角* 2:左下角* 3:右下角* 4:居中* param srcPath 视频路径* param wmImgPath 水印图片路径* return*/public static int[] getXy(int wmPosition,String srcPath,String wmImgPath){int x10,y10; //定义默认为左上角int[] xy new int[2];//获取视频信息VideoInfo videoInfo VideoInfoHelps.getVideoInfo(srcPath);int width 0; //视频宽int height 0; //视频高if(videoInfo ! null){String widthStr videoInfo.getWidth(); //宽if(StringUtils.isNotEmpty(widthStr)) width Integer.parseInt(widthStr);String heightStr videoInfo.getHeight(); //高if(StringUtils.isNotEmpty(heightStr)) height Integer.parseInt(heightStr);}if(width !0 || height !0){ //如果获取到视频宽高//取得坐标方位编码int position BaseCommonUtil.getWmDegree(wmPosition);int wideth_biao 0; //水印图片的宽int height_biao 0; //水印图片的高try {//首先进行图片缩放ImageHelps.zoomPerImg(wmImgPath, wmImgPath,width,height);//水印文件Image src_biao ImageIO.read(new File(wmImgPath));wideth_biao src_biao.getWidth(null);height_biao src_biao.getHeight(null);} catch (IOException e) {logger.error(【 wmImgPath 】getXy 读取水印图片失败 !);}//左上角距离边距10像素int leftUpWideth 10;int leftUpHeight 10;//右上角距离边距10像素int rightUpWideth (width - wideth_biao) - 10;int rightUpHeight 10;//左下角距离边距10像素int leftDownWideth 10;int leftDownHeight (height - height_biao) - 10;//右下角距离边距10像素int rightDownWideth (width - wideth_biao) - 10;int rightDownHeight (height - height_biao) - 10;//居中int centerWideth (width - wideth_biao) / 2;int centerHeight (height - height_biao) / 2;switch (position) {case 0:x leftUpWideth;y leftUpHeight;break;case 1:x rightUpWideth;y rightUpHeight;break;case 2:x leftDownWideth;y leftDownHeight;break;case 3:x rightDownWideth;y rightDownHeight;break;case 4:x centerWideth;y centerHeight;break;default:break;}}//设值xy[0] x;xy[1] y;return xy;}
http://www.zqtcl.cn/news/774954/

相关文章:

  • 西安网站建设和推广公司php企业网站开发实训报告
  • 市网站制作番禺绿叶居
  • 网站漂浮物怎么做电子商务网站开发实训体会
  • 电商网站建设定制济南网站建设及推广
  • 网站标签化wordpress 输出评论内容 函数
  • 明星个人网站设计汕头网络推广公司
  • 深圳有哪些做网站公司好武夷山建设局网站
  • 怎么设立网站赚广告费一个网站可以做多少关键字
  • 网站刚建好怎么做能让百度收录成都定制网站建
  • thinkphp网站开发技术做电脑租赁网站
  • 网站设计评语中午版wordpress
  • 邢台企业手机网站建设汕头网站制作后缀
  • 微网站后台内容设置做网站语言排名2018
  • 嘉兴网站制作网站建设外贸营销推广平台有哪些
  • 网站开发集广州高端网站定制开发价格
  • 网站开发培训成都网站建设 报价单 doc
  • 苏州哪里有做淘宝网站的WordPress模板博客主题
  • 网站做中转做任务 网站
  • 深圳住房建设局网站网站的建设教程
  • 6免费建站的网站在线建筑设计
  • 哪些网站做任务可以赚钱的建设厅网站如何查询企业信息
  • 深圳网站设计+建设首选深圳市服装网站建设需求分析报告
  • 肥城网站制作浙江省建设厅信息港官网
  • 手机网站建设进度南宁企业网站设计
  • 建设学校网站方案大淘客网站上的推广怎么做
  • 哪个网站可以免费学设计南阳网站建设页面
  • 外贸公司建网站一般多少钱南京网站建设小程
  • 洛阳霞光做网站公司手机编程教学
  • 深圳正规网站建设公司顺德网页制作公司
  • 消防中队网站建设筑云电商网站建设公司