linux系统下从源码安装FFmpeg、h264 、libfaac 在power8平台,rhel7.0 或者ubuntu14.04

声明:此文档只做学习交流使用,请勿用作其他商业用途

author:朝阳_tony
E-mail : linzhaolover@163.com
Create Date:2015-1-24 11:10:23 Saturday
Last Change:2015-1-24 11:38:31 Saturday
转载请注明出处: http://blog.csdn.net/linzhaolover


摘要:

最近在power8 平台上安装ffmpeg遇到了一点问题总结,说一些需要注意的地方,同时也是记录一下自己的安装过程,方便后期查阅,与大家一起分享一下;

有时候到找不到对应的程序安装包,只好自己从源码编译,然后安装对应的平台;

测试环境:

RedHat 系统 Big Endian

Red Hat Enterprise Linux Server release 7.0 (Maipo)
ppc64 power8 Big endian

#uname -a
Linux 3.10.0-123.el7.ppc64 #1 SMP Mon May 5 11:18:37 EDT 2014 ppc64 ppc64 ppc64 GNU/Linux

还有  Ubuntu14.04 系统 Little Endian

Distributor ID: Ubuntu
Description:    Ubuntu 14.04 LTS
Release:        14.04
Codename:       trusty

# uname -a
Linux 3.13.0-29-generic #53-Ubuntu SMP Wed Jun 4 21:02:53 UTC 2014 ppc64le ppc64le ppc64le GNU/Linux 

1、安装libx264 

git clone git://git.videolan.org/x264
./configure --prefix=/usr --libdir=/usr/lib64 --enable-shared
make install
一般自己的编译的代码,在安装的时候都会默认安装到/usr/local目录下,但有时候如果这个库需要被其他的软件引用,可能回导致无法找到等问题;

由于我的系统64位的,所以指定库的目录是lib64 ,

最后为了让其他库引用,需要enable shared ,


2、安装libfaac

平时我们在Ubuntu下最喜欢安装软件命令莫过于apt-get  了,

# apt-get install libfaac-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libfaac-dev
啥,没有安装包,

查看了一下faac的官网,http://www.audiocoding.com/index.html

原来有了新的安装包faad

apt-get install libfaad-dev

安装faad成功了,但我们想安装的是faac啊, 好吧,还是下载源码手动安装;

wget http://downloads.sourceforge.net/faac/faac-1.28.tar.gz
./configure --prefix=/usr --libdir=/usr/lib64
make install

上面是安装lib64目录,在ffmpeg中还调用不到;
还需要安装到lib目录下才行,
./configure --prefix=/usr --libdir=/usr/lib
make install

 
 

编译faac时遇到一个错误;是自己的定义与系统库中的头文件定义冲突,

In file included from mp4common.h:29:0,
                 from 3gp.cpp:28:
mpeg4ip.h:126:58: error: new declaration ‘char* strcasestr(const char*, const char*)’
 char *strcasestr(const char *haystack, const char *needle);
                                                          ^
In file included from mpeg4ip.h:107:0,
                 from mp4common.h:29,
                 from 3gp.cpp:28:
/usr/include/string.h:365:26: error: ambiguates old declaration ‘const char* strcasestr(const char*, const char*)’
 extern "C++" const char *strcasestr (const char *__haystack,
                          ^
临时解决办法,当然是修改自己的程序了,注释掉自身的

vim common/mp4v2/mpeg4ip.h
注释掉126行  char *strcasestr(const char *haystack, const char *needle);

3、安装FFmpeg 使能h264 、libfaac库

我写这篇文章时FFmpeg的版本是v2.5,

git clone git://source.ffmpeg.org/ffmpeg

./configure  --enable-gpl --enable-memory-poisoning --enable-avresample --cpu=power8 \
        --prefix=/usr \
        --libdir=/usr/lib64 \
        --enable-shared \
        --shlibdir=/usr/lib64 \
        --enable-nonfree \
        --enable-libx264 \
        --enable-libfaac

make -j8
make install
 

--cpu=power8 在p8平台,最好打开这个标志,这样可以使能很多的优化库;如果你的不是p8,请不要指定对应平台,或者用缺省值;

--enable-nonfree 由于FFmpeg支持很多费免费的库,而libfaac又是非free的库,所以必须打开这标志,

最后是能你想安装的库

--enable-libx264       --enable-libfaac


总结:

工作中经常遇到各样的问题,多开动脑筋,想想怎么做,大部分事情还是可以解决的;


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Linux 系统下使用 FFmpeg 解码 H.264 实时视频,可以按照以下步骤进行: 1. 安装 FFmpeg 首先需要安装 FFmpeg 库,可以使用以下命令在 Ubuntu 系统安装: ``` sudo apt-get install ffmpeg ``` 2. 编写代码 接下来需要编写 C++ 代码,使用 FFmpeg 库进行 H.264 视频解码。 示例代码如下: ```c++ #include <iostream> #include <fstream> #include <string.h> #include <stdio.h> extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> #include <libswscale/swscale.h> #include <libavutil/imgutils.h> } using namespace std; int main(int argc, char* argv[]) { AVFormatContext* pFormatCtx = NULL; AVCodecContext* pCodecCtx = NULL; AVCodec* pCodec = NULL; AVFrame* pFrame = NULL; AVFrame* pFrameRGB = NULL; uint8_t* buffer = NULL; int numBytes; if(argc < 2) { printf("Please provide a H264 video file.\n"); return -1; } av_register_all(); if(avformat_open_input(&pFormatCtx, argv[1], NULL, NULL) != 0) { printf("Error: Cannot open video file.\n"); return -1; } if(avformat_find_stream_info(pFormatCtx, NULL) < 0) { printf("Error: Cannot find stream information.\n"); return -1; } AVCodecParameters* pCodecParams = NULL; int videoStreamIndex = -1; for(int i = 0; i < pFormatCtx->nb_streams; i++) { if(pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { videoStreamIndex = i; pCodecParams = pFormatCtx->streams[i]->codecpar; break; } } if(videoStreamIndex == -1) { printf("Error: Cannot find video stream.\n"); return -1; } pCodec = avcodec_find_decoder(pCodecParams->codec_id); if(pCodec == NULL) { printf("Error: Cannot find codec.\n"); return -1; } pCodecCtx = avcodec_alloc_context3(pCodec); if(avcodec_parameters_to_context(pCodecCtx, pCodecParams) != 0) { printf("Error: Cannot copy codec parameters to context.\n"); return -1; } if(avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { printf("Error: Cannot open codec.\n"); return -1; } pFrame = av_frame_alloc(); pFrameRGB = av_frame_alloc(); if(pFrame == NULL || pFrameRGB == NULL) { printf("Error: Cannot allocate frames.\n"); return -1; } numBytes = av_image_get_buffer_size(AV_PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height, 1); buffer = (uint8_t*)av_malloc(numBytes * sizeof(uint8_t)); av_image_fill_arrays(pFrameRGB->data, pFrameRGB->linesize, buffer, AV_PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height, 1); AVPacket packet; int frameFinished = 0; struct SwsContext* sws_ctx = NULL; while(av_read_frame(pFormatCtx, &packet) >= 0) { if(packet.stream_index == videoStreamIndex) { avcodec_send_packet(pCodecCtx, &packet); while(avcodec_receive_frame(pCodecCtx, pFrame) == 0) { sws_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, AV_PIX_FMT_RGB24, SWS_BILINEAR, NULL, NULL, NULL); sws_scale(sws_ctx, pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize); sws_freeContext(sws_ctx); printf("Decoding frame %d\n", pCodecCtx->frame_number); } } av_packet_unref(&packet); } av_free(buffer); av_free(pFrameRGB); av_free(pFrame); avcodec_close(pCodecCtx); avformat_close_input(&pFormatCtx); return 0; } ``` 3. 编译代码 使用以下命令编译上述代码: ``` g++ -o decode_h264 decode_h264.cpp -lavformat -lavcodec -lswscale -lavutil ``` 4. 运行代码 使用以下命令运行编译好的代码: ``` ./decode_h264 input.h264 ``` 其中 `input.h264` 是待解码的 H.264 视频文件名。 以上就是在 Linux 系统下使用 FFmpeg 解码 H.264 实时视频的过程。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值