ChinaFFmpeg

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 12344|回复: 2

[Max OSX] 编译支持MP3与H264编码的ffmpeg

[复制链接]
发表于 2013-10-3 17:19:05 | 显示全部楼层 |阅读模式
作者 : www.chinaffmpeg.com 孙悟空

编译支持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: http://lame.sourceforge.net/download.php
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的话,可以使用如下参数进行支持
  1. ./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 - [url]http://www.videolan.org/x264.html[/url] - 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.      Author:    [url]www.chinaffmpeg.com[/url] 孙悟空
  41.     Stream #0:1(und): Audio: mp3 (libmp3lame) (i[0][0][0] / 0x0069), 44100 Hz, stereo, fltp, 128 kb/s (default)
  42.     Metadata:
  43.       handler_name    : SoundHandler
  44. Stream mapping:
  45.   Stream #0:0 -> #0:0 (h264 -> libx264)
  46.   Stream #0:1 -> #0:1 (aac -> libmp3lame)
  47. Press [q] to stop, [?] for help
  48. frame= 1568 fps=132 q=-1.0 Lsize=   13081kB time=00:01:03.32 bitrate=1692.3kbits/s dup=1 drop=0   
  49. video:12033kB audio:990kB subtitle:0 global headers:0kB muxing overhead 0.443282%
  50. [libx264 @ 0x7fc462030a00] frame I:10    Avg QP: 4.95  size: 31926
  51. [libx264 @ 0x7fc462030a00] frame P:559   Avg QP: 4.58  size: 13941
  52. [libx264 @ 0x7fc462030a00] frame B:999   Avg QP: 5.74  size:  4213
  53. [libx264 @ 0x7fc462030a00] consecutive B-frames: 11.0%  9.1%  9.6% 70.4%
  54. [libx264 @ 0x7fc462030a00] mb I  I16..4: 48.3% 32.6% 19.1%
  55. [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%
  56. [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%
  57. [libx264 @ 0x7fc462030a00] final ratefactor: 6.67
  58. [libx264 @ 0x7fc462030a00] 8x8 transform intra:48.6% inter:46.3%
  59. [libx264 @ 0x7fc462030a00] coded y,uvDC,uvAC intra: 75.9% 71.3% 59.6% inter: 19.2% 15.8% 10.6%
  60. [libx264 @ 0x7fc462030a00] i16 v,h,dc,p: 65% 19%  9%  8%
  61. [libx264 @ 0x7fc462030a00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 33% 13%  3%  4%  5%  6%  5%  6%
  62. [libx264 @ 0x7fc462030a00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 37% 10%  3%  5%  4%  5%  3%  4%
  63. [libx264 @ 0x7fc462030a00] i8c dc,h,v,p: 46% 28% 19%  6%
  64. [libx264 @ 0x7fc462030a00] Weighted P-Frames: Y:10.4% UV:4.8%
  65. [libx264 @ 0x7fc462030a00] ref P L0: 69.1% 15.4% 12.1%  3.3%  0.1%
  66. [libx264 @ 0x7fc462030a00] ref B L0: 87.2% 11.8%  1.1%
  67. [libx264 @ 0x7fc462030a00] ref B L1: 95.3%  4.7%
  68. [libx264 @ 0x7fc462030a00] kb/s:1571.58
  69. [StevenLiu@liudeMacBook-Pro ffmpeg]$ ffmpeg -i output.mp4
  70. ffmpeg version N-56530-g29f244e Copyright (c) 2000-2013 the FFmpeg developers
  71.   built on Sep 21 2013 16:41:16 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  72.   configuration: --enable-ffplay --enable-libmp3lame --enable-libx264 --enable-gpl
  73.   libavutil      52. 45.100 / 52. 45.100
  74.   libavcodec     55. 33.100 / 55. 33.100
  75.   libavformat    55. 18.102 / 55. 18.102
  76.   libavdevice    55.  3.100 / 55.  3.100
  77.   libavfilter     3. 86.102 /  3. 86.102
  78.   libswscale      2.  5.100 /  2.  5.100
  79.   libswresample   0. 17.103 /  0. 17.103
  80.   libpostproc    52.  3.100 / 52.  3.100
  81. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  82.   Metadata:
  83.     major_brand     : isom
  84.     minor_version   : 512
  85.     compatible_brands: isomiso2avc1mp41
  86.     encoder         : Lavf55.18.102
  87.   Duration: 00:01:03.34, start: 0.025057, bitrate: 1691 kb/s
  88.     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)
  89.     Metadata:
  90.       handler_name    : VideoHandler
  91.     Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 128 kb/s (default)
  92.     Metadata:
  93.       handler_name    : SoundHandler
  94. At least one output file must be specified
  95. [StevenLiu@liudeMacBook-Pro ffmpeg]$
复制代码
回复

使用道具 举报

发表于 2013-10-3 19:48:03 | 显示全部楼层
写的很好,谢谢!!!
回复 支持 反对

使用道具 举报

发表于 2013-10-4 07:59:37 | 显示全部楼层
谢谢分享,学习了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|Archiver|ChinaFFmpeg

GMT+8, 2024-12-27 12:53 , Processed in 0.049912 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表