x264

X264-编码模块和NAL打包输出

孤人 提交于 2019-12-06 04:43:44
在上一篇介绍了编码器的VCL编码操作,分析了函数x264_slice_write()。函数x264_slice_write()里有四个关键模块,分别是宏块分析模块、宏块编码模块、熵编码模块和滤波模块,再加上NAL打包输出部分,是我们这里要讲的内容。 1.编码模块 宏块分析模块:调用函数x264_macroblock_analyse()。分为两部分:帧内宏块和帧间宏块。帧内宏块用于分析帧内的预测模式,而帧间宏块进行运动估计,分析帧间的预测模式。 x264_macroblock_analyse(): void x264_macroblock_analyse( x264_t *h ) { x264_mb_analysis_t analysis; int i_cost = COST_MAX; //通过码率控制方法,获取本宏块QP h->mb.i_qp = x264_ratecontrol_mb_qp( h ); /* If the QP of this MB is within 1 of the previous MB, code the same QP as the previous MB, * to lower the bit cost of the qp_delta. Don't do this if QPRD is enabled. */ if( h->param.rc.i_aq

X264-视频压缩编码VCL

泪湿孤枕 提交于 2019-12-06 04:41:11
在前面的过程中,我们得到了编码图像,编码器开始H264视频编码VCL。首先初始化有关参数,包括帧类型的获取、创建多参考帧的列表、初始化码流控制、初始化写码流结构和写SPS、PPS头结构信息。 1.初始化相关参数 若为IDR帧,则意味着一个新图像片的开始。在H264中为了防止编码错误扩散,规定当前片不以本片以外的其他帧为参考,因而编码器遇到IDR帧则需要重置参考帧区域。同时,将SEI、SPS、PPS分别单独写入NAL单元。这三个参数集集合了编解码的核心参数,直接关系解码端能否正常解码。 若不是IDR帧,依据帧类型设定当前NAL单元的类型和图像片的类型。接着进行一系列初始化参数的操作,包括建立关于参考帧的list0和list1,初始化码流控制得到量化步长、参考帧等相关信息,初始化写比特流环境变量等。 在函数x264_lookahead_put_frame()中,将fenc放入lookanead.next.list[]队列,再调用函数x264_lookahead_get_frame()判断帧的类型。 x264_lookahead_get_frame(): //通过lookahead分析帧类型 void x264_lookahead_get_frames( x264_t *h ) { if( h->param.i_sync_lookahead ) { /* We have a

X264-libx264编码库

余生长醉 提交于 2019-12-06 04:40:11
X264编码库libx264实现真正的视频编解码,该编解码算法是基于块的混合编码技术,即帧内/帧间预测,然后对预测值变换、量化,最后熵编码所得。 编码帧的类型分为I帧(x264_type_i)、P帧(x264_type_p)、B帧(x264_type_b),在H264中叫做图像片Slice。 X264把整帧图像看作一个Slice,片中有slice_type_i、slice_type_p、slice_type_b之分。 I帧只有slice_type_i,P帧有slice_type_i、slice_type_p,B帧三种片都有。 X264的H264视频编码过程可以分为三个步骤:首先根据规则判定当前帧的编码类型,如果是B帧,要缓冲存放、获取;然后对待编码图像进行帧内预测、帧间预测、整数DCT变换、量化和熵编码;最后把压缩的H264数据进行NAL层打包输出。 X264编码器有关的重要结构体: x264_image_t:实际参与编码的编码帧图像信息。 typedef struct { int i_csp; //图像空间颜色 int i_plane; //图像平面数目 int i_stride[4]; //每个图像平面的跨度,也就是每一行数据的字节数 uint8_t *plane[4]; //每个图像平面存放数据的起始地址,plane[0]是Y平面,plane[1]是U平面,plane[2

X264-视频帧的存取

Deadly 提交于 2019-12-06 04:39:51
X264的编码器结构体x264_t中的子结构体字段frames包含了4个临时视频帧序列空间:current、next、unused和reference,分别保存当前编码帧、将编码帧序列、未处理原始视频帧序列和参考帧序列,同时x264编码器申请了fenc和fdec空间用于存放已编码帧和重建帧。H264中“帧”和“片”都是图像帧,如果不加说明,他们的意义基本一样。 编码器处理视频帧的顺序如下: 首先,从YUV视频文件中读取图像存储到临时x264_picture_t变量pic_in,同时为unused申请存储空间,并用fenc指针指向这个空间。 接着,将pic_in中的图片数据拷贝到fenc所指向的空间,并在拷贝完成后对图片大小进行判断,如果长宽不是16的整数,倍则进行像素扩展;将处理后的fenc区域数据放入next区域,之后,如果存在B帧,则从next区域中取出B帧以后的P帧放到current区域中,也就是说先编码I、P帧再编码其间的B帧;否则,则直接从next区域取出一帧存入current区域。此时,current区域中存放的就是已经预处理的即将要编码的帧数据了。 最后,由于fenc区域是编码的直接对象,再将current区域中的内容拷贝到fenc中正式开始编码。x264_encoder_encode()函数实现了这个过程。 x264_encoder_encode()

Writing numpy arrays using cv2 VideoWriter

不想你离开。 提交于 2019-12-05 14:19:50
I have a problem with writing a toy example video using opencv2.3.1 VideoWriter, here is how I do it: writer = cv2.VideoWriter('test1.avi',cv.CV_FOURCC('P','I','M','1'),25,(640,480)) for i in range(1000): x = np.random.randint(10,size=(480,640)).astype('uint8') writer.write(x) #del writer (with or without tested) I tried every possible combination resulting with a 0 bytes file if the extension was mpg, and 5.5kb if it was avi. I should say that some pointed out that I should build the ffmpeg library from source and not apt-get it. Well I did that on a fresh machine based on the help of this

Compiling x264 for iOS 5

假装没事ソ 提交于 2019-12-05 09:27:01
问题 I'm trying to compile the latest version of libx264 to iOS 5 arm. In mid-2010, the Gabriel script for building worked. It doesn't anymore. It says "No working C compiler found." Can anyone give me straight answer? It's 2012 and no one in google seems to have compiled it. 回答1: Update: I've added the needed files to the github repository below. https://github.com/rodisbored/ffmpeg_x264_iOS5_build I took gabriel's script and modified it. I've been meaning to post the complete script online, but

Windows: How to build X264.lib instead of .dll

帅比萌擦擦* 提交于 2019-12-05 08:31:40
问题 I downloaded the X264 source and installed mingw. Step 1: Executed this in the MINGW bash: ./configure --disable-cli --enable-shared --enable-win32thread - -extra-ldflags=-Wl,--output-def=libx264.def and then 'make' Step 2: Renamed the libx264-142.dll to libx264.dll and Opened up VS2012 Command Prompt and executed this: LIB /DEF:libx264.def which gave me libx264.lib and object libx264.exp Step 3: Included the lib file in a VS2012 project which uses the X264 API. Problem: When I start the

how to use x264 encoder with directshow

放肆的年华 提交于 2019-12-05 04:37:00
问题 i can't figure out how to use x264 with directshow. i installed many thinks that pretend to have x264 encoder in with no use i downloaded the videoLAN x264 binary and when i run it, it shows so fast a console windows, and nothing happen after that these is the encoders that i have i am working on windows 8.1 x64 please help with this issue it's just going to make me crazy hhh, i wanna use x264 because the other encoders that i have installed, either didn't work or encode with so big size. 回答1

ffmpeg安装ERROR: cuvid requested, but not all dependencies are satisfied: ffnvcodec

南笙酒味 提交于 2019-12-04 05:07:26
ERROR: cuvid requested, but not all dependencies are satisfied: ffnvcodec If you think configure made a mistake, make sure you are using the latest version from Git. If the latest version fails, report the problem to the ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net. Include the log file "ffbuild/config.log" produced by configure as this will help solve the problem. 解决方法:安装NVIDIA headers git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git make sudo make install 然后重新configure: PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --extra-cflags='-I/home

how to use x264 encoder with directshow

自古美人都是妖i 提交于 2019-12-03 21:19:28
i can't figure out how to use x264 with directshow. i installed many thinks that pretend to have x264 encoder in with no use i downloaded the videoLAN x264 binary and when i run it, it shows so fast a console windows, and nothing happen after that these is the encoders that i have i am working on windows 8.1 x64 please help with this issue it's just going to make me crazy hhh, i wanna use x264 because the other encoders that i have installed, either didn't work or encode with so big size. x264 itself does not have DirectShow interface, so you need a wrapper (or, you need to implement it