提到现在的互联网企业,阿里巴巴这家公司绝对是许多迎接毕业生们心所向往的地方,不光是高薪资待遇,还有阿里巴巴这个国内一线大厂的荣耀光环所加持,自然会吸引更多的年轻人们涌入。由于现在看见大厂对于招聘员工的学历水平要求越来越高,所以那些相对学历低的年轻人想要进入到想阿里巴巴这样的科技大厂,自然是变得越来越困难,不过阿里巴巴的创始人马云也曾经在不同的场合发表过言论,就是阿里巴巴对于人才的引进,并不会仅仅局限于学历上。

原创文章,欢迎转载。转载请注明:转载自IT人故事会,谢谢!原文链接地址:「小程序JAVA实战」小程序视频处理工具ffmpeg

前面已经把视频成功的上传到我们的服务器,选择了背景音乐的ID,现在需要把视频和背景音乐进行合并,需要使用一个工具ffmpeg。源码:
中wx-springboot 和 No.15

图片 1简单的python代码实现语音朗读

图片 2

ffmpeg

  • 介绍

视音频处理工具,跨平台的视音频处理解决方案,主页:

图片 3

  • 应用的场景
  1. 播放器:射手播放器,暴风影音,迅雷播放器……
  2. 转换工具:格式工厂,剪辑工具……
  3. 直播,视频加码,滤镜,水印,特效……
  • 下载

    图片 4

根据你的需求进行下载,我选择在windows平台来进行下载

图片 5图片 6图片 7

  • 测试

图片 8图片 9图片 10

C:\Users\Administrator>D:D:\>cd D:\Program Files\ffmpegD:\Program Files\ffmpeg>cd binD:\Program Files\ffmpeg\bin>ffmpeg.exe -i shanzhu.mp4 shanzhu.aviffmpeg version N-91949-g6304268e39 Copyright  2000-2018 the FFmpeg developers built with gcc 8.2.1  20180813 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth libavutil 56. 19.101 / 56. 19.101 libavcodec 58. 30.100 / 58. 30.100 libavformat 58. 18.100 / 58. 18.100 libavdevice 58. 4.103 / 58. 4.103 libavfilter 7. 31.100 / 7. 31.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'shanzhu.mp4': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: mp41mp42isom creation_time : 2018-09-16T05:29:47.000000Z Duration: 00:00:09.34, start: 0.000000, bitrate: 1210 kb/s Stream #0:0: Video: h264  (avc1 / 0x31637661), yuv420p(tv, bt709), 544x960, 1159 kb/s, 29.97 fps, 29.97 tbr, 600 tbn, 1200 tbc  Metadata: creation_time : 2018-09-16T05:29:47.000000Z handler_name : Core Media Video Stream #0:1: Audio: aac  (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 46 kb/s  Metadata: creation_time : 2018-09-16T05:29:47.000000Z handler_name : Core Media AudioStream mapping: Stream #0:0 -> #0:0 (h264  -> mpeg4  Stream #0:1 -> #0:1 (aac  -> mp3 (libmp3lame))Press [q] to stop, [?] for helpOutput #0, avi, to 'shanzhu.avi': Metadata: major_brand : mp42 minor_version : 1 compatible_brands: mp41mp42isom ISFT : Lavf58.18.100 Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 544x960, q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc  Metadata: creation_time : 2018-09-16T05:29:47.000000Z handler_name : Core Media Video encoder : Lavc58.30.100 mpeg4 Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1 Stream #0:1: Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 44100 Hz, mono, fltp  Metadata: creation_time : 2018-09-16T05:29:47.000000Z handler_name : Core Media Audio encoder : Lavc58.30.100 libmp3lameframe= 280 fps=0.0 q=31.0 Lsize= 1096kB time=00:00:09.34 bitrate= 961.3kbits/s speed=16.7xvideo:999kB audio:72kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.338377%

图片 11

  • java程序调用cmd转换视频

springboot-common中添加FFMpegTest

package com.idig8.utils;import java.io.BufferedReader;import java.io.InputStream;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List;public class FFMpegTest { private String ffmpegEXE; public FFMpegTest(String ffmpegEXE) { super(); this.ffmpegEXE = ffmpegEXE; } public void convertor(String videoInputPath, String videoOutputPath) throws Exception {// ffmpeg -i input.mp4 -y output.avi List<String> command = new ArrayList<>(); command.add(ffmpegEXE); command.add; command.add(videoInputPath); command.add; command.add(videoOutputPath); for (String c : command) { System.out.print; } ProcessBuilder builder = new ProcessBuilder; Process process = builder.start(); InputStream errorStream = process.getErrorStream(); InputStreamReader inputStreamReader = new InputStreamReader(errorStream); BufferedReader br = new BufferedReader(inputStreamReader); String line = ""; while ( (line = br.readLine != null ) { } if (br != null) { br.close(); } if (inputStreamReader != null) { inputStreamReader.close(); } if (errorStream != null) { errorStream.close(); } } public static void main(String[] args) { FFMpegTest ffmpeg = new FFMpegTest("D:\\Program Files\\ffmpeg\\bin\\ffmpeg.exe"); try { ffmpeg.convertor("D:\\Program Files\\ffmpeg\\bin\\shanzhu.mp4", "D:\\Program Files\\ffmpeg\\bin\\shanzhu.avi"); } catch (Exception e) { e.printStackTrace(); } }}
  • 视频音频合并命令

通过这种方式,可以让我们的mp4和我们的mp3 做一个结合。

ffmpeg.exe -i shanzhu.avi -i music.mp3 -t 10 -y 合并音乐和视频.avi

图片 12图片 13

D:\Program Files\ffmpeg\bin>ffmpeg.exe -i shanzhu.avi -i music.mp3 -t 10 -y 合并音乐和视频.aviffmpeg version N-91949-g6304268e39 Copyright  2000-2018 the FFmpeg developers built with gcc 8.2.1  20180813 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth libavutil 56. 19.101 / 56. 19.101 libavcodec 58. 30.100 / 58. 30.100 libavformat 58. 18.100 / 58. 18.100 libavdevice 58. 4.103 / 58. 4.103 libavfilter 7. 31.100 / 7. 31.100 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100Input #0, avi, from 'shanzhu.avi': Metadata: encoder : Lavf58.18.100 Duration: 00:00:09.38, start: 0.000000, bitrate: 957 kb/s Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 544x960 [SAR 1:1 DAR 17:30], 876 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 30k tbc Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, mono, fltp, 64 kb/s[mp3 @ 000001fcfa57d6c0] Estimating duration from bitrate, this may be inaccurateInput #1, mp3, from 'music.mp3': Duration: 00:00:33.47, start: 0.000000, bitrate: 320 kb/s Stream #1:0: Audio: mp3, 48000 Hz, stereo, fltp, 320 kb/sStream mapping: Stream #0:0 -> #0:0 (mpeg4  -> mpeg4  Stream #1:0 -> #0:1 (mp3  -> mp3 (libmp3lame))Press [q] to stop, [?] for helpOutput #0, avi, to '鍚堝苟闊充箰鍜岃棰?avi': Metadata: ISFT : Lavf58.18.100 Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p(progressive), 544x960 [SAR 1:1 DAR 17:30], q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc Metadata: encoder : Lavc58.30.100 mpeg4 Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1 Stream #0:1: Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp Metadata: encoder : Lavc58.30.100 libmp3lameframe= 280 fps=274 q=31.0 Lsize= 1076kB time=00:00:10.00 bitrate= 880.4kbits/s speed=9.79xvideo:892kB audio:157kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.510280%
  • java程序调用cmd转换视频增加音频

package com.idig8.utils;import java.io.BufferedReader;import java.io.InputStream;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List;public class MergeVideoMp3 { private String ffmpegEXE; public MergeVideoMp3(String ffmpegEXE) { super(); this.ffmpegEXE = ffmpegEXE; } public void convertor(String videoInputPath, String mp3InputPath, double seconds, String videoOutputPath) throws Exception {// ffmpeg.exe -i 苏州大裤衩.mp4 -i bgm.mp3 -t 7 -y 新的视频.mp4 List<String> command = new ArrayList<>(); command.add(ffmpegEXE); command.add; command.add(videoInputPath); command.add; command.add(mp3InputPath); command.add; command.add(String.valueOf; command.add; command.add(videoOutputPath); // for (String c : command) {// System.out.print;// } ProcessBuilder builder = new ProcessBuilder; Process process = builder.start(); InputStream errorStream = process.getErrorStream(); InputStreamReader inputStreamReader = new InputStreamReader(errorStream); BufferedReader br = new BufferedReader(inputStreamReader); String line = ""; while ( (line = br.readLine != null ) { } if (br != null) { br.close(); } if (inputStreamReader != null) { inputStreamReader.close(); } if (errorStream != null) { errorStream.close(); } } public static void main(String[] args) { MergeVideoMp3 ffmpeg = new MergeVideoMp3("D:\\Program Files\\ffmpeg\\bin\\ffmpeg.exe"); try { ffmpeg.convertor("D:\\Program Files\\ffmpeg\\bin\\shanzhu.mp4", "D:\\Program Files\\ffmpeg\\bin\\music.mp3", 7.1, "D:\\Program Files\\ffmpeg\\bin\\合并音乐和视频.avi"); } catch (Exception e) { e.printStackTrace(); } }}

昨天女友生日,因为她一直对生日无感,所以我也就没有准备什么礼物。想起元旦前写的自动测试的脚本,添加了语音来提示测试和报告错误。灵机一动,为什么不用这个语音来庆祝她生日快乐呢?

近日有位程序员网友或许是受到了马云言论的吸引,想要进入阿里,不过却担心自己只是一个大专学历,所以有点纠结是否要去阿里投递简历。他的帖子内容是这样的:阿里卡学历严格吗?猎头找到我要推阿里P7的岗位给我,但我是大专学历,目前工作也还不错,带一个不到20人的团队,氛围很好,纠结要不要花时间更新简历,去试一下?

开发功能

视频上传后通过java调用ffmpge.exe完成音乐和视频的合并,并将视频信息保存在数据库中。

  • 视频service开发VideoService

package com.idig8.service;import com.idig8.pojo.Videos;public interface VideoService { /** * 保存视频信息 * @param Id * @return */ public void saveVideo(Videos video);} 

VideoServiceImpl

package com.idig8.service.Impl;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Propagation;import org.springframework.transaction.annotation.Transactional;import com.idig8.mapper.BgmMapper;import com.idig8.pojo.Bgm;import com.idig8.service.BgmService;@Servicepublic class BgmServiceImpl implements BgmService { @Autowired private BgmMapper bgmMapper; @Transactional(propagation =Propagation.SUPPORTS) @Override public List<Bgm> queryBgmList(){ return bgmMapper.selectAll(); } @Transactional(propagation =Propagation.SUPPORTS) @Override public Bgm queryBgmById(String Id){ return bgmMapper.selectByPrimaryKey; }}

BgmService

package com.idig8.service;import java.util.List;import com.idig8.pojo.Bgm;public interface BgmService { /** * 获取所有的Bgm列表 * @return */ public List<Bgm> queryBgmList(); /** * 通过bgmId获取Bgm对象 * @param Id * @return */ public Bgm queryBgmById(String Id);} 

BgmServiceImpl

package com.idig8.service.Impl;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Propagation;import org.springframework.transaction.annotation.Transactional;import com.idig8.mapper.BgmMapper;import com.idig8.pojo.Bgm;import com.idig8.service.BgmService;@Servicepublic class BgmServiceImpl implements BgmService { @Autowired private BgmMapper bgmMapper; @Transactional(propagation =Propagation.SUPPORTS) @Override public List<Bgm> queryBgmList(){ return bgmMapper.selectAll(); } @Transactional(propagation =Propagation.SUPPORTS) @Override public Bgm queryBgmById(String Id){ return bgmMapper.selectByPrimaryKey; }}

VideoController

package com.idig8.controller;import java.io.File;import java.util.Date;import java.util.UUID;import org.apache.commons.lang3.StringUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Value;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import org.springframework.web.multipart.MultipartFile;import com.idig8.pojo.Bgm;import com.idig8.pojo.Videos;import com.idig8.service.BgmService;import com.idig8.service.VideoService;import com.idig8.utils.JSONResult;import com.idig8.utils.MergeVideoMp3;import com.idig8.utils.enums.VideoStatusEnum;import com.idig8.utils.file.FileUtil;import io.swagger.annotations.Api;import io.swagger.annotations.ApiImplicitParam;import io.swagger.annotations.ApiImplicitParams;import io.swagger.annotations.ApiOperation;import io.swagger.annotations.ApiParam;@RestController@Api(value="视频相关业务的接口", tags= {"视频相关业务的controller"})@RequestMappingpublic class VideoController extends BasicController { @Autowired private BgmService bgmService; @Autowired private VideoService videosService; @Value("${server.file.path}") private String fileSpace; @Value("${server.ffmpeg.path}") private String ffmpegexe; @ApiOperation(value="上传视频", notes="上传视频的接口") @ApiImplicitParams({ @ApiImplicitParam(name="userId", value="用户id", required=true, dataType="String", paramType="form"), @ApiImplicitParam(name="bgmId", value="背景音乐id", required=false, dataType="String", paramType="form"), @ApiImplicitParam(name="videoSeconds", value="背景音乐播放长度", required=true, dataType="String", paramType="form"), @ApiImplicitParam(name="videoWidth", value="视频宽度", required=true, dataType="String", paramType="form"), @ApiImplicitParam(name="videoHeight", value="视频高度", required=true, dataType="String", paramType="form"), @ApiImplicitParam(name="desc", value="视频描述", required=false, dataType="String", paramType="form") }) @PostMapping(value="/upload", headers="content-type=multipart/form-data") public JSONResult upload(String userId, String bgmId, double videoSeconds, int videoWidth, int videoHeight, String desc, @ApiParam(value="短视频", required=true) MultipartFile file) throws Exception { if (StringUtils.isBlank { return JSONResult.errorMsg("用户id不能为空..."); } // 文件保存的命名空间 String fileName = file.getOriginalFilename(); // 保存到数据库中的相对路径 String path = ""; String videOutPath = ""; try { path = FileUtil.uploadFile(file.getBytes(), fileSpace, fileName); } catch (Exception e) { e.getStackTrace(); return JSONResult.errorMsg(e.getMessage; } if(StringUtils.isNotBlank{ Bgm bgm = bgmService.queryBgmById; String mp3BgmPath = fileSpace + bgm.getPath(); MergeVideoMp3 mergeVideoMp3 = new MergeVideoMp3(ffmpegexe); String videOutPathName = UUID.randomUUID().toString()+".mp4"; File targetFile = new File(fileSpace + userId); if (!targetFile.exists { targetFile.mkdirs(); } videOutPath = "/"+userId+"/"+videOutPathName; String videoInput = fileSpace +path; mergeVideoMp3.convertor(videoInput, mp3BgmPath, videoSeconds, fileSpace +videOutPath); } Videos videos = new Videos(); videos.setAudioId; videos.setCreateTime(new Date; videos.setVideoDesc; videos.setId(UUID.randomUUID().toString; videos.setUserId; videos.setVideoHeight(videoHeight); videos.setVideoWidth(videoWidth); videos.setVideoPath(videOutPath); videos.setStatus(VideoStatusEnum.SUCCESS.value); videosService.saveVideo; return JSONResult.ok; }}

图片 14

PS:已经完成了视频的上传,并把相关的信息保存在数据库中。

图片 15

图片 16简单的python代码实现语音朗读

图片 17

身为设计公司市场经理的她对程序又是完全无知,
说不定她会觉得有意思。于是就有了以下的代码:

显然楼主现在的岗位不赖,不但自己带团队,而且也是自己喜欢的事情,并且在领导眼里一定地位不错。对于他想要到阿里投递简历的事情,网友们自然是有着自己的观点。下面是不分网友的观点:不建议去了,都带20人了,好好当事业干吧,或者你刚三十岁也可以过去闯闯。不是极度缺钱的话不建议去,差那点钱身体可能更累,因为你也不知道自己去一个怎么样的团队做什么事,现在这么好何必要走。

<pre style=”-webkit-tap-highlight-color: transparent; box-sizing:
border-box; font-family: Consolas, Menlo, Courier, monospace; font-size:
16px; white-space: pre-wrap; position: relative; line-height: 1.5;
color: rgb(153, 153, 153); margin: 1em 0px; padding: 12px 10px;
background: rgb(244, 245, 246); border: 1px solid rgb(232, 232, 232);
font-style: normal; font-variant-ligatures: normal; font-variant-caps:
normal; font-weight: normal; letter-spacing: normal; orphans: 2;
text-align: start; text-indent: 0px; text-transform: none; widows: 2;
word-spacing: 0px; -webkit-text-stroke-width: 0px;”> 1 import
winsound2 import win32com.client3 import time45 speak_out =
win32com.client.Dispatch(‘SAPI.SPVOICE’)67 def speak:8 print9
speak_out.Speak10 winsound.PlaySound(str, winsound.SND_ASYNC)1112
while:13 speak(“祝我亲爱的生日快乐”)14 speak(“永远年轻漂亮!”)15
speak(“今年马上有钱!”)16 time.sleep</pre>

发表评论

电子邮件地址不会被公开。 必填项已用*标注