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

企业网站建设开发多少钱有哪些搜索引擎网站

企业网站建设开发多少钱,有哪些搜索引擎网站,wordpress doc预览,为什么有的网站点不开使用ffmpeg软件转换网络视频,先从官网下载对应操作系统环境的包 注意:网络地址需要是视频格式结尾,例如.mp4,.flv 等 官网地址:Download FFmpeg window包: linux包: 如果下载缓慢,下载迅雷安装使用…

使用ffmpeg软件转换网络视频,先从官网下载对应操作系统环境的包

注意:网络地址需要是视频格式结尾,例如.mp4,.flv 等

官网地址:Download FFmpeg     

window包:

415b5111089d42a4a02116b3fb877065.png

linux包:

39729fa04ffc4bf895ce22971e583292.png

如果下载缓慢,下载迅雷安装使用下载。

解压缩后对应截图:

window:

4cc5ed2dd51f4e6f9c96cb846d54e438.png

linux:

16eb35142ad44511b8c0089bd9437a56.png

在maven项目的pom.xml引入依赖包:

 <dependency><groupId>net.bramp.ffmpeg</groupId><artifactId>ffmpeg</artifactId><version>0.7.0</version></dependency><dependency><groupId>org.bytedeco</groupId><artifactId>javacpp</artifactId><version>1.4.1</version></dependency><dependency><groupId>org.bytedeco</groupId><artifactId>javacv</artifactId><version>1.4.1</version></dependency><dependency><groupId>org.bytedeco.javacpp-presets</groupId><artifactId>ffmpeg-platform</artifactId><version>3.4.2-1.4.1</version></dependency>

引入类:

import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import net.bramp.ffmpeg.FFmpeg;
import net.bramp.ffmpeg.FFmpegExecutor;
import net.bramp.ffmpeg.FFprobe;
import net.bramp.ffmpeg.builder.FFmpegBuilder;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.FrameGrabber;
import org.bytedeco.javacv.Java2DFrameConverter;import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;

网络地址转换成本地视频方法:

 /*** 视频链接转换成本地视频* @param videoUrl* @param downloadPath* @return*/public static boolean downVideo(String videoUrl,String downloadPath){HttpURLConnection connection = null;InputStream inputStream = null;RandomAccessFile randomAccessFile = null;boolean re;try{URL url = new URL(videoUrl);connection = (HttpURLConnection) url.openConnection();connection.setRequestProperty("Range","bytes=0-");connection.connect();if (connection.getResponseCode() / 100 != 2){System.out.println("链接失败");return  false;}inputStream = connection.getInputStream();int downloaded = 0;int fileSize = connection.getContentLength();randomAccessFile = new RandomAccessFile(downloadPath,"rw");while (downloaded < fileSize){byte[] buffer = null;if (fileSize - downloaded >= 1000000){buffer = new byte[1000000];}else{buffer = new byte[fileSize - downloaded];}int read = -1;int currentDownload = 0;while (currentDownload < buffer.length){read = inputStream.read();buffer[currentDownload++] = (byte) read;}randomAccessFile.write(buffer);downloaded += currentDownload;}re = true;return re;} catch (Exception e) {e.printStackTrace();re = false;return re;}finally {try{connection.disconnect();inputStream.close();randomAccessFile.close();}catch (Exception e){e.printStackTrace();}}}

网站地址转换成本地视频后,再转换成mp4视频方法:

/*** 其他视频格式地址转换成mp4* @param orginalVideoPath 原视频地址* @param newMp4FilePath 新mp4地址* @return*/public static boolean otherVideoToMp4(String orginalVideoPath,String newMp4FilePath)  {try{String ffmpegPath = "";String ffprobePath = "";if (SystemUtils.isWindows()){//目录里放的文件没有提交保存,在本地测试的时候自行添加ffmpegPath = VideoCovertUtil.class.getResource("/ffmpegdir/win/bin/ffmpeg.exe").getPath();ffprobePath = VideoCovertUtil.class.getResource("/ffmpegdir/win/bin/ffprobe.exe").getPath();}else if (SystemUtils.isLinux()){/*ffmpegPath = VideoCovertUtil.class.getResource("/ffmpegdir/linux/ffmpeg").getPath();ffprobePath = VideoCovertUtil.class.getResource("/ffmpegdir/linux/ffprobe").getPath();*///在linux安装ffmpeg后配置路径//安装步骤:https://blog.csdn.net/ysushiwei/article/details/130162831ffmpegPath = "/usr/local/bin/ffmpeg";ffprobePath = "/usr/local/bin/ffprobe";}log.info("ffmpegPath:"+ffmpegPath);log.info("ffmpegPath:"+ffprobePath);FFmpeg fFmpeg = new FFmpeg(ffmpegPath);FFprobe fFprobe = new FFprobe(ffprobePath);FFmpegBuilder builder = new FFmpegBuilder().setInput(orginalVideoPath).addOutput(newMp4FilePath).done();FFmpegExecutor executor = new FFmpegExecutor(fFmpeg,fFprobe);executor.createJob(builder).run();log.info("执行完毕");return  true;}catch (IOException e){e.printStackTrace();return false;}}

window可以直接放在项目中,但是linux还需要配置。步骤如下。

1、将上方的linux包上传到服务器,解压缩:

tar -xvf ffmpeg-release-amd64-static.tar.xz

2、解压缩后进入根目录分别复制根目录下的ffmpeg和ffprobe到 /usr/local/bin/目录下:

sudo cp 解压缩目录/ffmpeg /usr/local/bin/
sudo cp 解压缩目录/ffprobe /usr/local/bin/

3.还要给文件设置权限,否则运行代码的时候报没有权限:

sudo chmod +x /usr/local/bin/ffmpeg

sudo chmod +x /usr/local/bin/ffprobe

4、最后检查是否配置成功,如果有内容输出来则成功:

ffmpeg -version

ffprobe -version

linux环境配置好后,即可正常解析.

从视频中提取封面和获取时长:

 /*** 获取视频的第一帧封面* @param filePath 视频地址* @param targetPath 视频封面地址*/public static void getCover(String filePath,String targetPath){try{// 视频地址FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(new File(filePath));grabber.start();Java2DFrameConverter converter = new Java2DFrameConverter();BufferedImage image = converter.convert(grabber.grabImage());// 本地图片保存地址ImageIO.write(image, "png", new File(targetPath));grabber.stop();image.flush();}catch (Exception e){e.printStackTrace();}}/*** 使用FFmpeg获取视频时长** @param path 视频文件地址* @return 时长,单位为秒* @throws IOException*/public static String getDuration(String path) {// 读取视频文件FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(path);try {grabber.start();} catch (FrameGrabber.Exception e) {e.printStackTrace();}// 获取视频长度(单位:秒)int duration = grabber.getLengthInFrames() / (int) grabber.getFrameRate();try {grabber.stop();} catch (FrameGrabber.Exception e) {e.printStackTrace();}return DateUtil.secondToTime(duration);}

由于视频转换下载等速度比较慢,推荐使用异步执行。我用的是若依的框架,代码如下。如用其他框架,可自行参考写异步操作

//异步执行方法。不会等待执行完才执行下一位
AsyncManager.me().execute(AsyncFactory.convertVideoNetUrl(video.getVideoPath(),video.getId(),Constants.CONVERT_VIDEO_NET_VIDEO_URL));#在AsyncManager类里自定义一个异步方法如下/*** * @param videNetUrl 视频网络地址* @param id 类id* @param entityClazz 类 0:视频 1:文章* @return 任务task*/public static TimerTask convertVideoNetUrl(final String videNetUrl,Long id,Integer entityClazz){return new TimerTask(){@Overridepublic void run(){if (entityClazz == null || id == null || StrUtil.isBlank(videNetUrl)){return;}if (entityClazz == 0){IVideoService videoService =  SpringUtils.getBean(IVideoService.class);Video video = videoService.selectVideoById(id);if (video == null){return;}//现在是上传视频地址//先转换视频地址到服务器//后缀String ext = video.getVideoPath().substring(video.getVideoPath().lastIndexOf("."));String videosubpath = StringUtils.format("{}/{}_{}{}", DateUtils.datePath(),IdUtils.fastSimpleUUID(), Seq.getId(Seq.uploadSeqType), ext);String downloadPath = null;try {downloadPath = FileUploadUtils.getAbsoluteFile(HqaConfig.getUploadPath() + "/", videosubpath).getAbsolutePath();}catch (Exception e){e.printStackTrace();}boolean downVideo = VideoCovertUtil.downVideo(video.getVideoPath(),downloadPath);if (downVideo && StrUtil.isNotBlank(downloadPath) && downloadPath != null){if (!ext.contains("mp4")){//下载成功后如果不是mp4格式,转换成mp4格式String newVideosubpath = StringUtils.format("{}/{}_{}{}", DateUtils.datePath(),IdUtils.fastSimpleUUID(), Seq.getId(Seq.uploadSeqType), ".mp4");String newMp4FilePath = null;try {newMp4FilePath = FileUploadUtils.getAbsoluteFile(HqaConfig.getUploadPath() + "/", newVideosubpath).getAbsolutePath();}catch (Exception e){e.printStackTrace();}boolean toMp4 = VideoCovertUtil.otherVideoToMp4(downloadPath,newMp4FilePath);if (toMp4 && StrUtil.isNotBlank(newMp4FilePath) && newMp4FilePath != null){//转换成功后删除之前下载过的视频地址,并且保存新的mp4地址if (new File(downloadPath).exists()){FileUtils.deleteFile(downloadPath);}if (newMp4FilePath.contains("\\")){newMp4FilePath = newMp4FilePath.replace("\\","/");}String newPath = newMp4FilePath.replace(HqaConfig.getProfile(),"/profile");video.setVideoPath(newPath);}}else{if (downloadPath.contains("\\")){downloadPath = downloadPath.replace("\\","/");}//保存地址String newPath = downloadPath.replace(HqaConfig.getProfile(),"/profile");video.setVideoPath(newPath);}//视频截图和时长//获取视频第一帧封面String parentPath = HqaConfig.getUploadPath()+"/"+ DateUtils.datePath();String fileName = IdUtils.fastSimpleUUID()+".png";String targetPath = parentPath+"/"+ fileName;try {FileUploadUtils.getAbsoluteFile(parentPath,fileName);} catch (IOException e) {e.printStackTrace();}String filePath = video.getVideoPath().replace("/profile","");filePath=HqaConfig.getProfile()+filePath;VideoCovertUtil.getCover(filePath,targetPath);video.setCover(targetPath.replace(HqaConfig.getProfile(),"/profile"));String  duration = VideoCovertUtil.getDuration(filePath);video.setDuration(duration);videoService.updateVideo(video);}}else if (entityClazz == 1){IArticleService articleService = SpringUtils.getBean(IArticleService.class);Article article = articleService.selectArticleById(id);if (article == null){return;}//现在是上传视频地址//先转换视频地址到服务器//后缀String ext = article.getVideoPath().substring(article.getVideoPath().lastIndexOf("."));String videosubpath = StringUtils.format("{}/{}_{}{}", DateUtils.datePath(),IdUtils.fastSimpleUUID(), Seq.getId(Seq.uploadSeqType), ext);String downloadPath = null;try {downloadPath = FileUploadUtils.getAbsoluteFile(HqaConfig.getUploadPath() + "/", videosubpath).getAbsolutePath();}catch (Exception e){e.printStackTrace();}boolean downVideo = VideoCovertUtil.downVideo(article.getVideoPath(),downloadPath);if (downVideo && StrUtil.isNotBlank(downloadPath) && downloadPath != null){if (!ext.contains("mp4")){//下载成功后如果不是mp4格式,转换成mp4格式String newVideosubpath = StringUtils.format("{}/{}_{}{}", DateUtils.datePath(),IdUtils.fastSimpleUUID(), Seq.getId(Seq.uploadSeqType), ".mp4");String newMp4FilePath = null;try {newMp4FilePath = FileUploadUtils.getAbsoluteFile(HqaConfig.getUploadPath() + "/", newVideosubpath).getAbsolutePath();}catch (Exception e){e.printStackTrace();}boolean toMp4 = VideoCovertUtil.otherVideoToMp4(downloadPath,newMp4FilePath);if (toMp4 && StrUtil.isNotBlank(newMp4FilePath) && newMp4FilePath != null){//转换成功后删除之前下载过的视频地址,并且保存新的mp4地址if (new File(downloadPath).exists()){FileUtils.deleteFile(downloadPath);}if (newMp4FilePath.contains("\\")){newMp4FilePath = newMp4FilePath.replace("\\","/");}String newPath = newMp4FilePath.replace(HqaConfig.getProfile(),"/profile");article.setVideoPath(newPath);}}else{if (downloadPath.contains("\\")){downloadPath = downloadPath.replace("\\","/");}//保存地址String newPath = downloadPath.replace(HqaConfig.getProfile(),"/profile");article.setVideoPath(newPath);}articleService.updateArticle(article);}}}};}


文章转载自:
http://cypsela.hkpn.cn
http://panspermia.hkpn.cn
http://sandpiper.hkpn.cn
http://judder.hkpn.cn
http://ductless.hkpn.cn
http://sericeous.hkpn.cn
http://mollisol.hkpn.cn
http://astarboard.hkpn.cn
http://parotoid.hkpn.cn
http://ostleress.hkpn.cn
http://vishnu.hkpn.cn
http://unprincipled.hkpn.cn
http://tragus.hkpn.cn
http://serac.hkpn.cn
http://verge.hkpn.cn
http://unpropitious.hkpn.cn
http://buttonless.hkpn.cn
http://metacontrast.hkpn.cn
http://diastatic.hkpn.cn
http://congou.hkpn.cn
http://unobservance.hkpn.cn
http://psychopath.hkpn.cn
http://capitulation.hkpn.cn
http://spreadable.hkpn.cn
http://geosychronous.hkpn.cn
http://areology.hkpn.cn
http://matripotestal.hkpn.cn
http://agassiz.hkpn.cn
http://agminate.hkpn.cn
http://batrachian.hkpn.cn
http://whether.hkpn.cn
http://arboriculturist.hkpn.cn
http://washbasin.hkpn.cn
http://beira.hkpn.cn
http://aminobenzene.hkpn.cn
http://maratha.hkpn.cn
http://spermatocide.hkpn.cn
http://cognoscible.hkpn.cn
http://dodder.hkpn.cn
http://archibald.hkpn.cn
http://pyknic.hkpn.cn
http://absorb.hkpn.cn
http://disparagement.hkpn.cn
http://belongings.hkpn.cn
http://tarnishable.hkpn.cn
http://desquamate.hkpn.cn
http://epigamic.hkpn.cn
http://rusk.hkpn.cn
http://hydrodrome.hkpn.cn
http://bookseller.hkpn.cn
http://deathy.hkpn.cn
http://canary.hkpn.cn
http://observational.hkpn.cn
http://selenodesy.hkpn.cn
http://peltate.hkpn.cn
http://yarmouth.hkpn.cn
http://herodian.hkpn.cn
http://lichen.hkpn.cn
http://bors.hkpn.cn
http://pulpiness.hkpn.cn
http://barbeque.hkpn.cn
http://settecento.hkpn.cn
http://monodisperse.hkpn.cn
http://weaponry.hkpn.cn
http://briefly.hkpn.cn
http://averroism.hkpn.cn
http://roan.hkpn.cn
http://grabby.hkpn.cn
http://leonardesque.hkpn.cn
http://courtling.hkpn.cn
http://mahometan.hkpn.cn
http://paynim.hkpn.cn
http://expensive.hkpn.cn
http://grunion.hkpn.cn
http://infusionist.hkpn.cn
http://rakish.hkpn.cn
http://anecdote.hkpn.cn
http://textured.hkpn.cn
http://gillnet.hkpn.cn
http://xavier.hkpn.cn
http://sinfonia.hkpn.cn
http://merino.hkpn.cn
http://intermarriage.hkpn.cn
http://hedera.hkpn.cn
http://brandade.hkpn.cn
http://spondylitis.hkpn.cn
http://anthracosilicosis.hkpn.cn
http://butcherly.hkpn.cn
http://cavortings.hkpn.cn
http://hungover.hkpn.cn
http://glutamine.hkpn.cn
http://hydrodrill.hkpn.cn
http://on.hkpn.cn
http://joneses.hkpn.cn
http://cpo.hkpn.cn
http://confederate.hkpn.cn
http://integrate.hkpn.cn
http://pertness.hkpn.cn
http://tass.hkpn.cn
http://thingification.hkpn.cn
http://www.hrbkazy.com/news/75117.html

相关文章:

  • 最好的ppt模板网站火蝠电商代运营靠谱吗
  • 做任务拍照片赚钱的网站如何做营销活动
  • 怎么介绍自己做的网站推广拉新app哪几个靠谱
  • 法人变更在哪个网站做公示饥饿营销案例
  • 旅游资讯网站开发论文免费网站制作软件平台
  • 哪些网站做简历合适关键词优化包含
  • 用table做的网站优化模型有哪些
  • 怎么在搜索引擎里做网站网页搜索引擎优化心得体会
  • 做网站线西安百度竞价开户
  • 中小企业有哪些公司长安网站优化公司
  • 做网站用什么网最好市场营销实务
  • 怎样做 网站的快捷链接沈阳优化网站公司
  • 湖南营销型企业网站开发如何建网站
  • wordpress发送邮件插件网站站长seo推广
  • 微网站如何建立简述seo
  • 使用h5做的学习网站源码百度seo点击器
  • 做影视网站算侵权吗网站制作报价表
  • 网站开发开票编码归属seo前线
  • 长沙响应式网站设计有哪些域名whois查询
  • 中国建设银行网站缴费系统免费网站推广网站在线
  • 武功网站建设百度推广管理
  • 做网站多久能盈利全网营销
  • 泊头公司做网站优化大师tv版
  • seo排名优化培训班seo模拟点击
  • 图书馆网站参考咨询建设seo文章优化技巧
  • flash网站链接怎么做sem推广托管公司
  • 自己做的网站出现乱码付费推广平台有哪些
  • python制作的网站优化方案模板
  • 网站售后服务模板网站源码建站
  • 专业做网站登录淘宝关键词排名查询网站