背景

ffmpeg bin工具 可能无法满足产品的使用,于是需要通过传参调用ffmpeg库,即在通过更底层的方式使用它。

FFmpeg 介绍

FFmpeg是领先的多媒体框架,能够解码,编码,转码,复用,解复用,流,过滤和播放人类和机器创造的任何东西。它支持最多种类的编码格式。无论他们是由某个标准委员会,社区或公司设计的。
它也非常便于携带:FFmpeg在各种构建环境,机器体系结构和配置下编译,运行并通过Linux,Mac OS X,Microsoft Windows,BSD,Solaris等测试基础架构FATE。

它包含:
1.库:可供应用程序使用的libavcodec,libavutil,libavformat,libavfilter,libavdevice,libswscale和libswresample支持类库。
2.工具:ffmpeg,ffplay和ffprobe应用程序可供最终用户用于转码和播放。

FFmpeg Tools

ffmpeg用于在不同格式之间转换多媒体文件的命令行工具;
ffplay 基于SDL和FFmpeg库的简单媒体播放器;
ffprobe个简单的多媒体流分析器;

FFmpeg Libraries for developers:

libavutil是一个包含简化编程功能的库,包括随机数生成器,数据结构,数学例程,核心多媒体实用程序等等。

The libavutil library is a utility library to aid portable multimedia programming. It contains safe portable string functions, random number generators, data structures, additional mathematics functions, cryptography and multimedia related functionality (like enumerations for pixel and sample formats). It is not a library for code needed by both libavcodec and libavformat.

The goals for this library is to be:

  • Modular
    It should have few interdependencies and the possibility of disabling individual parts during ./configure.

  • Small
    Both sources and objects should be small.

  • Efficient
    It should have low CPU and memory usage.

  • Useful
    It should avoid useless features that almost no one needs.

libswscale是一个执行高度优化的图像缩放和色彩空间/像素格式转换操作的库。

The libswscale library performs highly optimized image scaling and colorspace and pixel format conversion operations.

Specifically, this library performs the following conversions:

  • Rescaling : is the process of changing the video size. Several rescaling options and algorithms are available. This is usually a lossy process.

  • Pixel format conversion : is the process of converting the image format and colorspace of the image, for example from planar YUV420P to RGB24 packed. It also handles packing conversion, that is converts from packed layout (all pixels belonging to distinct planes interleaved in the same buffer), to planar layout (all samples belonging to the same plane stored in a dedicated buffer or "plane").

This is usually a lossy process in case the source and destination colorspaces differ.

libswresample是一个库,用于执行高度优化的音频重采样,重新矩阵化和采样格式转换操作。

The libswresample library performs highly optimized audio resampling, rematrixing and sample format conversion operations.

Specifically, this library performs the following conversions:

  • Resampling: is the process of changing the audio rate, for example from a high sample rate of 44100Hz to 8000Hz. Audio conversion from high to low sample rate is a lossy process. Several resampling options and algorithms are available.
  • Format conversion: is the process of converting the type of samples, for example from 16-bit signed samples to unsigned 8-bit or float samples. It also handles packing conversion, when passing from packed layout (all samples belonging to distinct channels interleaved in the same buffer), to planar layout (all samples belonging to the same channel stored in a dedicated buffer or "plane").
  • Rematrixing: is the process of changing the channel layout, for example from stereo to mono. When the input channels cannot be mapped to the output streams, the process is lossy, since it involves different gain factors and mixing.

    Various other audio conversions (e.g. stretching and padding) are enabled through dedicated options.

libavcodec是一个包含音频/视频编解码器解码器和编码器的库。

The libavcodec library provides a generic encoding/decoding framework and contains multiple decoders and encoders for audio, video and subtitle streams, and several bitstream filters.

The shared architecture provides various services ranging from bit stream I/O to DSP optimizations, and makes it suitable for implementing robust and fast codecs as well as for experimentation.

libavformatis a library containing demuxers and muxers for multimedia container formats.

he libavformat library provides a generic framework for multiplexing and demultiplexing (muxing and demuxing) audio, video and subtitle streams. It encompasses multiple muxers and demuxers for multimedia container formats.

It also supports several input and output protocols to access a media resource.

libavdevice是一个包含输入和输出设备的库,用于抓取并渲染许多常见的多媒体输入/输出软件框架,包括Video4Linux,Video4Linux2,VfW和ALSA。

The libavdevice library provides a generic framework for grabbing from and rendering to many common multimedia input/output devices, and supports several input and output devices, including Video4Linux2, VfW, DShow, and ALSA.

libavfilter是一个包含媒体过滤器的库。

The libavfilter library provides a generic audio/video filtering framework containing several filters, sources and sinks.

FFmpeg中的数据结构

  • AVFormatContext 封装格式上下文结构体,也是统领全局的结构体,保存了视频文件封装 格式相关信息。

    • iformat:输入视频的AVInputFormat
    • nb_streams :输入视频的AVStream 个数
    • streams :输入视频的AVStream []数组
    • duration :输入视频的时长(以微秒为单位)
    • bit_rate :输入视频的码率
  • AVInputFormat 每种封装格式(例如FLV, MKV, MP4, AVI)对应一个该结构体。
    • name:封装格式名称
    • long_name:封装格式的长名称
    • extensions:封装格式的扩展名
    • id:封装格式ID
    • 一些封装格式处理的接口函数
  • AVStream 视频文件中每个视频(音频)流对应一个该结构体。
    • id:序号
    • codec:该流对应的AVCodecContext
    • time_base:该流的时基
    • r_frame_rate:该流的帧率
  • AVCodecContext编码器上下文结构体,保存了视频(音频)编解码相关信息。
    • codec:编解码器的AVCodec
    • width, height:图像的宽高(只针对视频)
    • pix_fmt:像素格式(只针对视频)
    • sample_rate:采样率(只针对音频)
    • channels:声道数(只针对音频)
    • sample_fmt:采样格式(只针对音频)
  • AVCodec 每种视频(音频)编解码器(例如H.264解码器)对应一个该结构体。
    • name:编解码器名称
    • long_name:编解码器长名称
    • type:编解码器类型
    • id:编解码器ID
    • 一些编解码的接口函数
  • AVPacket 存储一帧压缩编码数据。
    • pts:显示时间戳
    • dts :解码时间戳
    • data :压缩编码数据
    • size :压缩编码数据大小
    • stream_index :所属的AVStream
  • AVFrame存储一帧解码后像素(采样)数据。
    • data:解码后的图像像素数据(音频采样数据)。
    • linesize:对视频来说是图像中一行像素的大小;对音频来说是音频帧的大小。
    • width, height:图像的宽高(只针对视频)。
    • key_frame:是否为关键帧(只针对视频) 。
    • pict_type:帧类型(只针对视频) 。例如I,P,B。

参考资料:https://blog.csdn.net/leixiaohua1020/article/details/11693997

ffmpeg 学习:000-概述和库的组成的更多相关文章

  1. ffmpeg学习笔记-Linux下编译Android动态库

    Android平台要使用ffmpeg就需要编译生成动态库,这里采用Ubuntu编译Android动态库 文件准备 要编译生成Android需要以下文件 NDK ffmpeg源代码 NDK下载 NDK可 ...

  2. FFmpeg学习5:多线程播放视音频

    在前面的学习中,视频和音频的播放是分开进行的.这主要是为了学习的方便,经过一段时间的学习,对FFmpeg的也有了一定的了解,本文就介绍了 如何使用多线程同时播放音频和视频(未实现同步),并对前面的学习 ...

  3. FFmpeg学习起步 —— 环境搭建

    下面是我搭建FFmpeg学习环境的步骤. 一.在Ubuntu下 从http://www.ffmpeg.org/download.html下载最新的FFmpeg版本,我的版本是ffmpeg-2.7.2. ...

  4. FFMPEG学习----打印视频信息

    FFMPEG学习资料少之又少,在此推荐雷神的博客: http://blog.csdn.net/leixiaohua1020 在这里,我们把打印视频里的相关信息作为学习FFMPEG的 Hello Wor ...

  5. ffmpeg 学习:001-搭建开发环境

    介绍 由于命令行的ffmpeg工具无法满足产品的性能要求,需要对视频流进行兼容.所以需要调试有关的参数. FFmpeg全名是Fast Forward MPEG(Moving Picture Exper ...

  6. Google之Chromium浏览器源码学习——base公共通用库(二)

    上次提到Chromium浏览器中base公共通用库中的内存分配器allocator,其中用到了三方库tcmalloc.jemalloc:对于这两个内存分配器,个人建议,对于内存,最好是自己维护内存池: ...

  7. 从Theano到Lasagne:基于Python的深度学习的框架和库

    从Theano到Lasagne:基于Python的深度学习的框架和库 摘要:最近,深度神经网络以“Deep Dreams”形式在网站中如雨后春笋般出现,或是像谷歌研究原创论文中描述的那样:Incept ...

  8. IOS学习:常用第三方库(GDataXMLNode:xml解析库)

    IOS学习:常用第三方库(GDataXMLNode:xml解析库) 解析 XML 通常有两种方式,DOM 和 SAX: DOM解析XML时,读入整个XML文档并构建一个驻留内存的树结构(节点树),通过 ...

  9. FFmpeg 学习(五):FFmpeg 编解码 API 分析

    在上一篇文章 FFmpeg学习(四):FFmpeg API 介绍与通用 API 分析 中,我们简单的讲解了一下FFmpeg 的API基本概念,并分析了一下通用API,本文我们将分析 FFmpeg 在编 ...

  10. FFmpeg 学习(七):FFmpeg 学习整理总结

    一.FFmpeg 播放视频的基本流程整理 播放流程: video.avi(Container) -> 打开得到 Video_Stream -> 读取Packet -> 解析到 Fra ...

随机推荐

  1. 研究Zookeeper的原理(二)

    阅读声明:以下内容是结合网上材料及工作内容所写的个人理解,如有不当,欢迎大家指正~~~谢谢啦 一.ZooKeeper的选举机制.FailOver机制 我们知道ZooKeeper在分布式环境中协调服务, ...

  2. django xadmin中logout页面在chrome浏览器中点击关闭页面无效

    问题现象 django xadmin中logout页面在chrome浏览器中点击关闭页面无效,无法关闭相应的页面 问题原因 高版本的chrome等浏览器不支持在window.colse()的写法 问题 ...

  3. 一键绑定-提供一键动态绑定键盘输入的效果[C#制作](2020年寒假小目标07)

    日期:2020.01.31 博客期:139 星期五 [需求部分] 嗯,其实我是找了一下网站,要实现按下一个键盘键可以按照顺序输出想要的多个键盘键,差不多就是这样的功能.为什么我会有想实现这样功能的想法 ...

  4. Python 中命令行参数解析工具 docopt 安装和应用

    什么是 docopt? 1.docopt 是一种 Python 编写的命令行执行脚本的交互语言. 它是一种语言! 它是一种语言! 它是一种语言! 2.使用这种语言可以在自己的脚本中,添加一些规则限制. ...

  5. js判断对象中是否存在某一项和判断是否是对象

    1.判断是否为对象 let str = { name: '第一', age: 12 } console.log(typeof str== "object") 2.判断对象中是否有某 ...

  6. pycharm中Terminal中运行用例

     1.设置终端路径 2.单个用例文件运行 3.多个用例文件,例如加载用例的文件运行 1.可能会出现如下错误(参考:https://blog.csdn.net/qq_36829091/article/d ...

  7. 学习不一样的vue4:mock与axios实战1

    学习不一样的vue4:mock与axios实战1  发表于 2017-06-14 |  分类于 web前端|  |  阅读次数 8180 首先 首发博客: 我的博客 项目源码: 源码(喜欢请star) ...

  8. JS - 处理浏览器兼容之 event

    function test(e){ var event = e || windows.event   //  IE : windows.event  ,非IE : e }

  9. Python 基础之循环结构 while

    一.while循环介绍 while 循环 可以提高代码的效率,减少代码的冗余 while 条件表达式:    code1    code2如果条件表达式成立,返回Ture,就执行其中的代码块 1.基本 ...

  10. Java 在Excel单元格中应用一种/多种字体样式

    在Excel表格中,设置单元格字体样式时,可以对单元格内的所有字符应用同一样式,即获取指定单元,应用样式即可:另外也可以对单元格内的不同字符内容应用不同字体样式,即获取单元格中的字符位置,应用样式:本 ...