- 浏览: 38221 次
文章分类
最新评论
1.前言
由于最近在做ios与android端需要做amr至mp3的转换,在网上搜了下资料,基本都是用ffmpeg做音视频类转换
2.ffmpeg下载安装
2.1、下载ffmpeg。
下载网址:http://www.ffmpeg.org/download.html
2.2、解压缩
2.3、编辑profile文件:
vi /etc/profile
在文件末尾加上两句话:
2.4、配置安装路径之类的:
2.5、编译安装
2.6、安装之后在/usr/local/ffmpeg会看到有三个目录
2.7、为了防止执行程序找不到库文件,
8、若出现error while loading shared libraries: libavdevice.so.52的错误
3.shell脚本命令转换
4.ffmpeg自带转换
5.Jave转换
下载地址:http://www.sauronsoftware.it/projects/jave/download.php
备注:
如果自带的FFmpeg转码报错,编译最新的ffmpeg,执行就可以了
官方示例:
由于最近在做ios与android端需要做amr至mp3的转换,在网上搜了下资料,基本都是用ffmpeg做音视频类转换
2.ffmpeg下载安装
2.1、下载ffmpeg。
下载网址:http://www.ffmpeg.org/download.html
2.2、解压缩
tar -zxvf ffmpeg-2.0.1.tar.gz
2.3、编辑profile文件:
vi /etc/profile
在文件末尾加上两句话:
export FFMPEG_HOME=/usr/local/ffmpeg export PATH=$FFMPEG_HOME/bin:$PATH
2.4、配置安装路径之类的:
./configure --enable-shared --prefix=/usr/local/ffmpeg --enable-shared 参数据说是允许其编译产生动态库,在以后的编程中要用到这个几个动态库,我也没考证,就直接用了。 如果出现异常,提示因为缺少yasm,需要添加参数,再执行以下命令: ./configure --enable-shared --disable-yasm --prefix=/usr/local/ffmpeg 如果执行结果不对,可以根据提示信息,并查看帮助,解决问题 ./configure --help
2.5、编译安装
make make install
2.6、安装之后在/usr/local/ffmpeg会看到有三个目录
bin 执行文件目录 lib 静态,动态链接库目录 include 编程用到的头文件
2.7、为了防止执行程序找不到库文件,
可以将/usr/local/ffmpeg/lib目录设置到LD_LIBRARY_PATH环境变量
8、若出现error while loading shared libraries: libavdevice.so.52的错误
修改/etc/ld.so.conf 在最后一行加上/usr/local/ffmpeg/lib ldconfig -v 并修改 /usr/local/ffmpeg/lib目录下的文件权限为777
3.shell脚本命令转换
./ffmpeg -i source.amr dest.mp3
4.ffmpeg自带转换
/** * useFfmpegToMp3 * * @param ffmpeg * @param source * @param target */ public static void useFfmpegToMp3(String ffmpeg, String source, String target){ Runtime run = null; try { long start=System.currentTimeMillis(); run = Runtime.getRuntime(); //设置文件运行权限 run.exec(new String[] { "/bin/chmod", "755", ffmpeg}); String runCmd = ffmpeg + " -i " + source + " " + target; //运行命令 Process proc = run.exec(runCmd); proc.getOutputStream().flush(); proc.getOutputStream().close(); proc.getInputStream().close(); LOGGER.info("Dest File Size:{}", new File(target).length()); long end=System.currentTimeMillis(); LOGGER.info("useFfmpegToMp3 Complete:{} -> {}, cost ms:{}", source, target, end-start); } catch (Exception e) { LOGGER.error("useJaveToMp3 Exception: ", e); } finally{ //run调用lame解码器最后释放内存 run.freeMemory(); } }
5.Jave转换
下载地址:http://www.sauronsoftware.it/projects/jave/download.php
/** * jave 转换mp3 * * @param source * @param target */ public static void useJaveToMp3(String source, String target) { try { long start=System.currentTimeMillis(); File sourceFile = new File(source); File targetFile = new File(target); AudioAttributes audio = new AudioAttributes(); Encoder encoder = new Encoder(); audio.setCodec("libmp3lame"); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("mp3"); attrs.setAudioAttributes(audio); encoder.encode(sourceFile, targetFile, attrs); LOGGER.info("Dest File Size:{}", targetFile.length()); long end=System.currentTimeMillis(); LOGGER.info("useJaveToMp3 Complete:{} -> {}, cost ms:{}", source, target, end-start); }catch (Exceptio){ LOGGER.error("useJaveToMp3 Exception: ", e); } }
备注:
如果自带的FFmpeg转码报错,编译最新的ffmpeg,执行就可以了
官方示例:
//From a generic AVI to a youtube-like FLV movie, with an embedded MP3 audio stream: File source = new File("source.avi"); File target = new File("target.flv"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("libmp3lame"); audio.setBitRate(new Integer(64000)); audio.setChannels(new Integer(1)); audio.setSamplingRate(new Integer(22050)); VideoAttributes video = new VideoAttributes(); video.setCodec("flv"); video.setBitRate(new Integer(160000)); video.setFrameRate(new Integer(15)); video.setSize(new VideoSize(400, 300)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("flv"); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs); //Next lines extracts audio informations from an AVI and store them in a plain WAV file: File source = new File("source.avi"); File target = new File("target.wav"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("pcm_s16le"); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("wav"); attrs.setAudioAttributes(audio); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs); // Next example takes an audio WAV file and generates a 128 kbit/s, stereo, 44100 Hz MP3 file: File source = new File("source.wav"); File target = new File("target.mp3"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("libmp3lame"); audio.setBitRate(new Integer(128000)); audio.setChannels(new Integer(2)); audio.setSamplingRate(new Integer(44100)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("mp3"); attrs.setAudioAttributes(audio); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs); // Next one decodes a generic AVI file and creates another one with the same video stream of the source and a re-encoded low quality MP3 audio stream: File source = new File("source.avi"); File target = new File("target.avi"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("libmp3lame"); audio.setBitRate(new Integer(56000)); audio.setChannels(new Integer(1)); audio.setSamplingRate(new Integer(22050)); VideoAttributes video = new VideoAttributes(); video.setCodec(VideoAttributes.DIRECT_STREAM_COPY); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("avi"); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs); //Next one generates an AVI with MPEG 4/DivX video and OGG Vorbis audio: File source = new File("source.avi"); File target = new File("target.avi"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("libvorbis"); VideoAttributes video = new VideoAttributes(); video.setCodec("mpeg4"); video.setTag("DIVX"); video.setBitRate(new Integer(160000)); video.setFrameRate(new Integer(30)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("mpegvideo"); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs); // A smartphone suitable video: File source = new File("source.avi"); File target = new File("target.3gp"); AudioAttributes audio = new AudioAttributes(); audio.setCodec("libfaac"); audio.setBitRate(new Integer(128000)); audio.setSamplingRate(new Integer(44100)); audio.setChannels(new Integer(2)); VideoAttributes video = new VideoAttributes(); video.setCodec("mpeg4"); video.setBitRate(new Integer(160000)); video.setFrameRate(new Integer(15)); video.setSize(new VideoSize(176, 144)); EncodingAttributes attrs = new EncodingAttributes(); attrs.setFormat("3gp"); attrs.setAudioAttributes(audio); attrs.setVideoAttributes(video); Encoder encoder = new Encoder(); encoder.encode(source, target, attrs);
发表评论
-
JVM内存结构及分析
2017-07-16 19:38 525JVM内存模型 名称特征 ... -
JVM调优实例
2017-06-24 12:30 01.背景:由于最近上线新增业务模块,业务量要增加所以对上线服务 ... -
git did not match any file(s) known to git
2016-04-23 23:49 29501.did not match any file(s) kno ... -
Static工具类线程安全问题
2016-01-08 11:39 22981.静态方法 无论是静态方法还是实例方法,在内存中都只 ... -
JavaThread-ThreadLocal笔记
2015-12-23 14:54 5041.ThreadLocal简介 早在JDK 1.2的版本中就提 ... -
JUC-CountDownLatch笔记
2015-12-23 10:53 5341.CountDownLatch简介 CountDownLat ... -
Lambda表达式实现设计模式:命令模式
2015-10-13 09:59 668如何在使用Java 8 Lambda表达式的函数式编程方式时实 ... -
mysql 错误汇总
2015-08-12 16:49 4111.Mysql ERROR 1045 (28000): Acc ... -
Java注解
2015-08-07 11:25 01.@Retention(RetentionPolicy.RU ... -
Base64 编解码 工具类
2015-07-28 22:48 42451.工具类: import java.io.Uns ... -
HttpClient(发送字符串,multipart, 参数等)
2015-07-10 11:12 2032备注:httpclient4.5 发送MultiPart/Pa ... -
转载-搜索引擎实时秒级更新
2015-07-08 14:02 832搜索是很多用户在天 ... -
tomcat-定时任务
2015-03-30 15:27 6101.监听类 import java.util.Timer ... -
JVM-工作原理
2015-03-16 23:26 612一、 JVM的生命周期 1. J ... -
tomcat-启动时启动额外线程并控制线程状态
2015-02-04 18:22 634通过启动线程可以进行后台的操作 1.创建servlet ... -
Exception in thread "main" SoapFault - faultcode: 'soapenv:Server.userException'
2015-01-20 22:32 13501.抛出此类错误大部分都是服务端发布webservice调用出 ... -
Tomcat映射虚拟目录
2015-01-19 22:43 01.设置虚拟目录 <Host>标签</H ... -
android-运行java main方法
2014-12-30 16:10 6841.右键入口类(含有Main方法的)Run Configura ... -
Mybatis 常见错误汇总
2014-12-28 22:31 01.插入数据到数据库是异常 ### Cause: java.s ... -
jsoup
2014-12-17 00:25 01. package com.wuhao.itinfo ...
相关推荐
视频格式转换的需求普遍存在,通过FFMPEG这个开源免费的软件...实验结果表明:FFMPEG软件可以很好地实现视频格式转换,并可按需求改变其中的视频编码方式和音频编码方式,可灵活地转换视频格式,并具有很强的可移植性。
ffmpeg-0.5编码包,适合于windows下的音视频开发,可以进行视频转换和编解码
利用QT和FFmpeg实现类似于格式工厂的功能,进行简单的音视频处理。
它包括了目前领先的音/视频编码库libavcodec。 FFmpeg是在 Linux 下开发出来的,但它可以在包括 Windows 在内的大多数操作系统中编译。这个项目是由 Fabrice Bellard 发起的,现在由 Michael Niedermayer 主持。可以...
通过调用FFmpeg库的接口,我们可以实现音频的录制和播放,并能够对音频进行格式转换、编码解码等操作。 开发环境搭建 在开始开发之前,我们需要搭建适合iOS平台的开发环境。我们将使用Xcode作为主要的集成开发环境...
它包括了目前领先的音/视频编码库libavcodec。 FFmpeg是在 Linux 下开发出来的,但它可以在包括 Windows 在内的大多数操作系统中编译。这个项目是由 Fabrice Bellard 发起的,现在由 Michael Niedermayer 主持。可以...
它包括了目前领先的音/视频编码库libavcodec。 FFmpeg是在 Linux 下开发出来的,但它可以在包括 Windows 在内的大多数操作系统中编译。这个项目是由 Fabrice Be【ffmpeg-4.3.1(linux-mac-window)】 1、ffmpeg-4.3.1-...
FFmpeg支持众多音视频编码格式,如MP3、AAC、AC3、H.264、MPEG-4等。它可以将不同格式的音视频文件转换为其他格式,从而满足不同设备和平台的需求。除了转换格式,FFmpeg还可以进行音视频的剪切、合并、裁剪、旋转等...
它包括了目前领先的音/视频编码库libavcodec。 FFmpeg是在 Linux 下开发出来的,但它可以在包括 Windows 在内的大多数操作系统中编译。这个项目是由 Fabrice Bellard 发起的,现在由 Michael Niedermayer 主持。可以...
它提供了录制、转换以及流化音视频的完整解决方案。它包含了非常先进的音频/视频编解码库libavcodec,为了保证高可移植性和编解码质量,libavcodec里很多code都是从头开发的。 FFmpeg在Linux平台下开发,但它同样也...
它包括了目前领先的音/视频编码库libavcodec。 FFmpeg是在 Linux 下开发出来的,但它可以在包括 Windows 在内的大多数操作系统中编译。这个项目是由 Fabrice Bellard 发起的,现在由 Michael Niedermayer 主持。可以...
ffmpeg库,音视频编解码,FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。它包括了目前领先的音/视频编码库libavcodec。
1. 分离音视频 2. 解复用 3. 视频转码 4. 视频封装 5. 视频剪切 6. 视频录制 7.叠加水印 8.将MP3转换为PCM数据 9. 推送RTP流、接收RTP流并存为ts文件 10. ffmpeg 编码 11. ffmpeg 解码 12. 截取 YUV 13....
它包括了目前领先的音/视频编码库libavcodec。 FFmpeg是在 Linux 下开发出来的,但它可以在包括 Windows 在内的大多数操作系统中编译。这个项目是由 Fabrice Bellard 发起的,现在由 Michael Niedermayer 主持。可以...
它提供了录制、转换以及流化音视频的完整解决方案。它包含了非常先进的音频/视频编解码库libavcodec,为了保证高可移植性和编解码质量,libavcodec里很多code都是从头开发的。 FFmpeg在Linux平台下开发,但它同样也...
它提供了录制、转换以及流化音视频的完整解决方案。它包含了非常先进的音频/视频编解码库libavcodec,为了保证高可移植性和编解码质量,libavcodec里很多code都是从头开发的。 FFmpeg在Linux平台下开发,但它同样也...
它包括了目前领先的音/视频编码库libavcodec。 FFmpeg是在 Linux 下开发出来的,但它可以在包括 Windows 在内的大多数操作系统中编译。这个项目是由 Fabrice Bellard 发起的,现在由 Michael Niedermayer 主持。可以...
ffmpeg是一个很强大的音视频处理工具,官网是:http://ffmpeg.org/ 官网介绍ffmpeg是:一个完整的、跨平台的解决方案,可以记录、转换和传输音频和视频。ffmpeg既可以播放视频,也提供命令行工具来处理视频,另外...
音视频转换:FFmpeg可以将视频文件从一种格式转换为另一种格式,支持几乎所有流行的视频和音频格式。 解码和编码:FFmpeg包含许多不同的解码器和编码器,可以用于转换视频和音频数据。 复用和解复用:FFmpeg可以...
它提供了录制、转换以及流化音视频的完整解决方案。 FFmpeg是一套可以用来记录、转换数字音频、视频,并能将其转化为流的开源计算机程序。它包括了目前领先的音/视频编码库libavcodec等。 libavformat :用于各种音...