【问题标题】:Relation between lineSize, width, height in FFMPEGFFMPEG中lineSize,width,height之间的关系
【发布时间】:2019-05-19 08:45:38
【问题描述】:

我对 AVFrame 中的 linesize、height、width 感到困惑。

据我了解,linesize 是步幅,理想情况下应该是图像的宽度,对吧?

但是,width 和 linesize 的值不匹配。

AVFrame pFrame; 
cout<<"PFrame Linesize :"<<pFrame->data.linesize[0]<<endl;
cout<<"PFrame Width :"<<pFrame->width<<endl;

输出:

PFrame Linesize : 64
PFrame width : 12

我的框架尺寸为 12*12。

根据对此post 的回答,linesize 应该与 width 相同。但我无法理解为什么它们在这里不同。

【问题讨论】:

  • 我不认为这是重复的。根据那篇文章,linesize 应该与宽度相同。这不是我的情况。
  • 它们本质上并不相同,尽管它们是相关的。步幅是行的大小(以字节为单位)。你的框架是什么格式的?
  • 我正在尝试解码一个 mpeg 文件,并且想要获取 YUV 值。我猜格式是 YUV_420。

标签: c++11 ffmpeg codec libav


【解决方案1】:

我在这里引用文档:

 * For video, size in bytes of each picture line.
 * For audio, size in bytes of each plane.
 *
 * For audio, only linesize[0] may be set. For planar audio, each channel
 * plane must be the same size.
 *
 * For video the linesizes should be multiples of the CPUs alignment
 * preference, this is 16 or 32 for modern desktop CPUs.
 * Some code requires such alignment other code can be slower without
 * correct alignment, for yet other it makes no difference.
 *
 * @note The linesize may be larger than the size of usable data -- there
 * may be extra padding present for performance reasons.

所以视频的 linesize 是

宽度 * 每个像素的字节数 + 行填充

它将您从一行图像/帧数据的开头带到下一行的开头。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-28
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    • 2017-10-11
    • 1970-01-01
    • 2023-01-22
    • 1970-01-01
    相关资源
    最近更新 更多