Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2353413
  • 博文数量: 141
  • 博客积分: 3552
  • 博客等级: 中校
  • 技术积分: 4148
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-15 14:39
个人简介

熟悉Linux下程序设计及各种应用程序 熟悉C Language 熟悉Glusterfs、FFmpeg、CDN 系统设计,计算机图形系统设计、分布式程序设计 目前主要研究方向:流媒体

文章分类

全部博文(141)

分类: LINUX

2013-10-03 17:47:00

编译支持MP3,H264编码的ffmpeg

ffmpeg原有的系统中支持mp3和h264的解码,但是编码并不支持,所以,需要是应用第三方插件进行支持;

从configure --help可以看出:


点击(此处)折叠或打开

  1. [StevenLiu@liudeMacBook-Pro ffmpeg]$ ./configure --help
  2.   --enable-libstagefright-h264 enable H.264 decoding via libstagefright [no]
  3.   --enable-libx264 enable H.264 encoding via x264 [no]
  4.  --enable-libmp3lame enable MP3 encoding via libmp3lame [no]


首先系统中需要包含libx264与libmp3lame,这两个lib能够从对应的git中下载得到

MP3编码对应web:

libx264对应Web: http://www.videolan.org/developers/x264.html

安装mp3编码库


点击(此处)折叠或打开

  1. ./configure
  2. make
  3. make install


安装libx264编码库

 孙悟空

点击(此处)折叠或打开

  1. ./configure
  2. make
  3. make install


当安装的过程中遇到需要yasm的时候,可以--disabled-yasm,当然,并不建议disabled调,还是安装yasm更好一些

如果需要支持h264与mp3的话,可以使用如下参数进行支持

./configure --enable-libmp3lame --enable-libx264 --enable-gpl

由于libx264的code有GPL信息,所以,支持libx264时,需要--enable-gpl,ffmpeg在license方面还是比我们国内的人更重视

然后make&&make install即编译安装ffmpeg

接下来可以试一下

ok,生成完毕


点击(此处)折叠或打开

  1. [StevenLiu@liudeMacBook-Pro ffmpeg]$ ffmpeg -i test.mp4 -vcodec libx264 -b:v 1200k -r 25 -acodec mp3 -ab 128k -ar 44100 output.mp4
  2. ffmpeg version N-56530-g29f244e Copyright (c) 2000-2013 the FFmpeg developers
  3.   built on Sep 21 2013 16:41:16 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  4.   configuration: --enable-ffplay --enable-libmp3lame --enable-libx264 --enable-gpl
  5.   libavutil 52. 45.100 / 52. 45.100
  6.   libavcodec 55. 33.100 / 55. 33.100
  7.   libavformat 55. 18.102 / 55. 18.102
  8.   libavdevice 55. 3.100 / 55. 3.100
  9.   libavfilter 3. 86.102 / 3. 86.102
  10.   libswscale 2. 5.100 / 2. 5.100
  11.   libswresample 0. 17.103 / 0. 17.103
  12.   libpostproc 52. 3.100 / 52. 3.100
  13. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  14.   Metadata:
  15.     major_brand : isom
  16.     minor_version : 512
  17.     compatible_brands: isomiso2avc1mp41
  18.     encoder : Lavf55.18.102
  19.   Duration: 00:01:03.32, start: 0.021333, bitrate: 408 kb/s
  20.     Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 278 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
  21.     Metadata:
  22.       handler_name : VideoHandler
  23.     Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 126 kb/s (default)
  24.     Metadata:
  25.       handler_name : SoundHandler
  26. File 'output.mp4' already exists. Overwrite ? [y/N] y
  27. [libx264 @ 0x7fc462030a00] using SAR=1/1
  28. [libx264 @ 0x7fc462030a00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
  29. [libx264 @ 0x7fc462030a00] profile High, level 3.0
  30. [libx264 @ 0x7fc462030a00] 264 - core 130 r2274 c832fe9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=1200 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
  31. Output #0, mp4, to 'output.mp4':
  32.   Metadata:
  33.     major_brand : isom
  34.     minor_version : 512
  35.     compatible_brands: isomiso2avc1mp41
  36.     encoder : Lavf55.18.102
  37.     Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x352 [SAR 1:1 DAR 20:11], q=-1--1, 1200 kb/s, 12800 tbn, 25 tbc (default)
  38.     Metadata:
  39.       handler_name : VideoHandler
  40.     Stream #0:1(und): Audio: mp3 (libmp3lame) (i[0][0][0] / 0x0069), 44100 Hz, stereo, fltp, 128 kb/s (default)
  41.     Metadata:
  42.       handler_name : SoundHandler
  43. Stream mapping:
  44.   Stream #0:0 -> #0:0 (h264 -> libx264)
  45.   Stream #0:1 -> #0:1 (aac -> libmp3lame)
  46. Press [q] to stop, [?] for help
  47. frame= 1568 fps=132 q=-1.0 Lsize= 13081kB time=00:01:03.32 bitrate=1692.3kbits/s dup=1 drop=0
  48. video:12033kB audio:990kB subtitle:0 global headers:0kB muxing overhead 0.443282%
  49. [libx264 @ 0x7fc462030a00] frame I:10 Avg QP: 4.95 size: 31926
  50. [libx264 @ 0x7fc462030a00] frame P:559 Avg QP: 4.58 size: 13941
  51. [libx264 @ 0x7fc462030a00] frame B:999 Avg QP: 5.74 size: 4213
  52. [libx264 @ 0x7fc462030a00] consecutive B-frames: 11.0% 9.1% 9.6% 70.4%
  53. [libx264 @ 0x7fc462030a00] mb I I16..4: 48.3% 32.6% 19.1%
  54. [libx264 @ 0x7fc462030a00] mb P I16..4: 2.2% 5.6% 2.9% P16..4: 20.3% 11.4% 8.9% 0.0% 0.0% skip:48.8%
  55. [libx264 @ 0x7fc462030a00] mb B I16..4: 0.1% 0.3% 0.3% B16..8: 21.7% 5.6% 2.1% direct: 4.2% skip:65.8% L0:40.3% L1:43.8% BI:15.9%
  56. [libx264 @ 0x7fc462030a00] final ratefactor: 6.67
  57. [libx264 @ 0x7fc462030a00] 8x8 transform intra:48.6% inter:46.3%
  58. [libx264 @ 0x7fc462030a00] coded y,uvDC,uvAC intra: 75.9% 71.3% 59.6% inter: 19.2% 15.8% 10.6%
  59. [libx264 @ 0x7fc462030a00] i16 v,h,dc,p: 65% 19% 9% 8%
  60. [libx264 @ 0x7fc462030a00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 33% 13% 3% 4% 5% 6% 5% 6%
  61. [libx264 @ 0x7fc462030a00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 37% 10% 3% 5% 4% 5% 3% 4%
  62. [libx264 @ 0x7fc462030a00] i8c dc,h,v,p: 46% 28% 19% 6%
  63. [libx264 @ 0x7fc462030a00] Weighted P-Frames: Y:10.4% UV:4.8%
  64. [libx264 @ 0x7fc462030a00] ref P L0: 69.1% 15.4% 12.1% 3.3% 0.1%
  65. [libx264 @ 0x7fc462030a00] ref B L0: 87.2% 11.8% 1.1%
  66. [libx264 @ 0x7fc462030a00] ref B L1: 95.3% 4.7%
  67. [libx264 @ 0x7fc462030a00] kb/s:1571.58
  68. [StevenLiu@liudeMacBook-Pro ffmpeg]$ ffmpeg -i output.mp4
  69. ffmpeg version N-56530-g29f244e Copyright (c) 2000-2013 the FFmpeg developers
  70.   built on Sep 21 2013 16:41:16 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  71.   configuration: --enable-ffplay --enable-libmp3lame --enable-libx264 --enable-gpl
  72.   libavutil 52. 45.100 / 52. 45.100
  73.   libavcodec 55. 33.100 / 55. 33.100
  74.   libavformat 55. 18.102 / 55. 18.102
  75.   libavdevice 55. 3.100 / 55. 3.100
  76.   libavfilter 3. 86.102 / 3. 86.102
  77.   libswscale 2. 5.100 / 2. 5.100
  78.   libswresample 0. 17.103 / 0. 17.103
  79.   libpostproc 52. 3.100 / 52. 3.100
  80. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  81.   Metadata:
  82.     major_brand : isom
  83.     minor_version : 512
  84.     compatible_brands: isomiso2avc1mp41
  85.     encoder : Lavf55.18.102
  86.   Duration: 00:01:03.34, start: 0.025057, bitrate: 1691 kb/s
  87.     Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 1571 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
  88.     Metadata:
  89.       handler_name : VideoHandler
  90.     Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 128 kb/s (default)
  91.     Metadata:
  92.       handler_name : SoundHandler
  93. At least one output file must be specified
  94. [StevenLiu@liudeMacBook-Pro ffmpeg]$


阅读(15892) | 评论(1) | 转发(3) |
给主人留下些什么吧!~~

xiaoshao02052014-10-30 16:35:52

文明上网,理性发言...