Ffmpeg

作者: 寂静台风 | 来源:发表于2019-01-06 16:01 被阅读0次

    1、什么是ffmpeg


    image.png

    ffmpeg参考文档
    http://www.imooc.com/t/4873493(推荐)

    ffmpeg 命令分类


    image.png

    FFmpeg处理音视频流程

    image.png

    多媒体文件的基本概念
    1、多媒体文件其实是个容器
    2、在容器中有很多流
    3、每种流是由不同的编码器的。
    4、从流中读出的数据称为包
    5、在一个包中包含一个或多个帧

    几种重要的结构体
    1、AVFormatContext
    2、AVStream
    3、AVPacket

    Ffmpeg操作流数据的基本操作


    image.png

    打印音视频信息
    1、av_register_all():将ffmpeg中的编解码、注册
    2、avformat_open_input()/avformat_close_input
    3、av_dump_format()

    抽取音频数据
    1、av_init_packet():初始化一个数据包结构体。
    2、av_find_best_stream()
    3、av_read_frame()/av_packet_unref()

    中级开发内容

    1、H264解码
    2、H264编码
    3、AAC解码
    4、AAC编码

    1、添加头文件
    libavcodec/avcodec.h(编解码 库)

    2、常用的数据结构体
    AVCodec编码器结构体
    AVCodecContext编辑器上下文
    AVFrame解码后的帧

    3、结构体内存的分配与释放
    av_frame_alloc/av_frame_free()
    avcodec_alloc_context()
    avcodec_free_context()

    4、解码步骤
    1、查找解码器:avcodec_find_decoder
    2、创造上下文
    3、打开解码器:avcodec_open2
    4 、解码:avcodec_decode_video2

    5、H264编码流程
    1、查找解码器:avcodec_find_encoder_by_name
    2、创造上下文
    3、设置编码参数,并打开编码器:avcodec_open2
    4、编码:avcodec_encode_video2

    6、Ffmpng aac编码
    1、编码的流程与视频相同
    2、编码函数avcodec_encodec_audio2

    Android 平台下引入ffmpeg

    1、编译android下的ffmpeg的库文件
    2、在android中引入编译好的动态库

    3、编写CMakeLists.txt
    1、android 自带的库


    image.png

    2、编写自己的动态库文件


    image.png

    3、引入ffmpeg动态库
    imported表示引入的库


    image.png

    4、引入动态库的头文件


    引入动态库的头文件
    5、链接所有的库生快native-lib库
    image.png

    相关文章

      网友评论

          本文标题:Ffmpeg

          本文链接:https://www.haomeiwen.com/subject/kiqdrqtx.html