X264解码器完整帧不在一个NAL单元中 [英] X264 Decoder complete frame not come in one NAL Unit

查看:165
本文介绍了X264解码器完整帧不在一个NAL单元中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用libX264库进行编码.在将数据编码为NAL Unit()的形式后......这是我需要的相同格式(AVC),但问题是一帧进入两个Nal单元(一帧=(length,data)+(length,数据))和我需要的(一帧=(长度,数据)以单个单位).当我将其转换为文件然后播放时,它首先显示屏幕的上部,然后显示下部.我的配置参数如下

I am using libX264 library for encoding purpose . After encoding data is in form of NAL Unit ()..... .This is same format( AVC) what I require but problem is one frame come in two Nal Unit ( One frame = (length,data) + (length,data) ) and i need ( One frame = (length,data) in single nal unit).While I am converting into file then play , it show first upper part of screen and then lower . My config parameter are below

param.i_width = 1680//;
param.i_height = 948;
param.i_fps_num = some no;
param.i_fps_den = 1;
param.i_keyint_max = 1 ;
param.rc.i_rc_method = //;
param.rc.f_rf_constant = //;
param.rc.f_rf_constant_max = //;
param.rc.b_mb_tree = 1;
param.rc.i_vbv_max_bitrate = ; // Convert to Kbps
param.rc.i_vbv_buffer_size = param.rc.i_vbv_max_bitrate / param.i_fps_num;
param.b_repeat_headers = 0;
param.b_annexb = 0;

推荐答案

您可以发送编码器代码吗?通常,您应该具有以下代码:

Can you send your encoder code? Normally you should have the following code:

naluSize=x264_encoder_encode(h, &nal, &i_nal, pic, &pic_out);
if(naluSize_size>0)
{
    memcpy(Framebuffer, nal[0].p_payload, frame_naluSize);
    FrameBufferSize= frame_naluSize;
}

因此,您将已编码的帧保存在Framebuffer中,其大小在FrameBufferSize中.在我的应用程序中,这就像一个魅力.

So you will have your encoded frame in Framebuffer and its size is in FrameBufferSize. This works like a charm in my application.

另一建议是不要触摸任何您不知道的参数(至少要解决问题之前).只需使用

Another advice is not to touch any parameters (at least till you solve your problems) that you don't have any idea about. Just use

x264_param_default_preset(&param, "ultrafast", "zerolatency");

这将为您设置许多参数.当然,不要忘记设置分辨率:)

This will set many parameters for you. Of course, don't forget to set the resolution :)

这篇关于X264解码器完整帧不在一个NAL单元中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆