Using libavformat and libavcodec(2)
来源:互联网 发布:php编程培训 编辑:程序博客网 时间:2024/06/05 07:02
Decoding Video Frames
As I've already mentioned, a video file can contain several audio and video streams, and each of those streams is split up into packets of a particular size. Our job is to read these packets one by one using libavformat, filter out all those that aren't part of the video stream we're interested in, and hand them on to libavcodec for decoding. In doing this, we'll have to take care of the fact that the boundary between two frames can occur in the middle of a packet.
Sound complicated? Luckily, we can encapsulate this whole process in a routine that simply returns the next video frame:
Now, all we have to do is sit in a loop, calling GetNextFrame() until it return false. Just one more thing to take care of: Most codecs return images in YUV420(one luminance and two chrominance channels, with the chrominance channels samples at half the spatial resolution of the luminance channel). Depending on what you want to do with the video data, you may want to convert this to RGB. (Note, though, that this is not necessary if all you want to do is diplay the video data; take a look at the X11 Xvideo extension, which does YUV-to-RGB and scaling in hardware.) Fortunately, libavcodec provides a conversion routine called img_convert, which does conversion between YUV and RGB as well as a variety of other image formats. The loop that decodes the video thus becomes:
The RGB image pFrameRGB(of type AVFrame*) is allocated like this:
- Using libavformat and libavcodec(2)
- Using libavformat and libavcodec
- Using libavformat and libavcodec
- Using libavformat and libavcodec
- Using libavformat and libavcodec
- Using libavformat and libavcodec(1)
- Using libavformat and libavcodec(3)
- 【zz】Using libavformat and libavcodec
- 【转载】How to use libavformat and libavcodec
- libavformat/libavcodec学习
- libavformat/libavcodec学习
- libavformat/libavcodec 学习
- libavformat/libavcodec学习
- libavformat/libavcodec学习(mplayer)
- libavformat/libavcodec 学习
- libavformat/libavcodec学习(转)
- libavformat/libavcodec学习
- libavformat/libavcodec 学习
- linux 无盘启动
- Hibernate 中boolean类型属性问题
- linux centos rpm包管理 更新
- Lightbox相册,图片滚动和点击放大
- 大小乔的经历告诉我们:有才有钱又长得帅的男人,一般没法陪你到最后。董卓的下场告诉我们:儿子是不能乱认的,尤其是有前科的,更何况自己是大款,为得家产甘当孙子的都有
- Using libavformat and libavcodec(2)
- 印度-多了解了一点点
- 在Window.onload中加载/执行多个函数
- ubuntu ipv6访问youtube
- 你是如何成为 Lisp 程序员的
- 一个晶体管管放大电路实验总结
- 北方的东
- AS3.0 中的一些优化操作
- 开门帖!