简体   繁体   English

X264:如何从编码器访问NAL单元?

[英]X264 : How to access NAL units from encoder?

When I call 我打电话的时候

frame_size = x264_encoder_encode(encoder, &nals, &i_nals, &pic_in, &pic_out);

and subsequently write each NAL to a file like this: 然后将每个NAL写入如下文件:

     if (frame_size >= 0)
     {
        int i;
        int j;

        for (i = 0; i < i_nals; i++)
        {
           printf("******************* NAL %d (%d bytes) *******************\n", i, nals[i].i_payload);
           fwrite(&(nals[i].p_payload[0]), 1, nals[i].i_payload, fid);
        }
     }

then I get this 然后我明白了

NAL文件的开头

My questions are: 我的问题是:

1) Is it normal that there's readable parameters in the beginning of the file? 1)文件开头的可读参数是否正常?

2) How do I configure the X264 encoder so that the encoder returns frames that I can send via UDP without the packet getting fragmented (size must be below 1390 or somewhere around that). 2)如何配置X264编码器,以便编码器返回可以通过UDP发送的帧,而不会使数据包碎片化(大小必须低于1390或其周围)。

3) With the x264.exe I pass in these options: 3)使用x264.exe我传递了以下选项:

"--threads 1 --profile baseline --level 3.2 --preset ultrafast --bframes 0 --force-cfr --no-mbtree --sync-lookahead 0 --rc-lookahead 0 --keyint 1000 --intra-refresh" 

How do I map those to the settings in the X264 parameters structure ? 如何将这些映射到X264参数结构中的设置? (x264_param_t) (x264_param_t)

4) I have been told that the x264 static library doesn't support bitmap input to the encoder and that I have to use libswscale for conversion of the 24bit RGB input bitmap to YUV2. 4)我被告知x264静态库不支持对编码器的位图输入,并且我必须使用libswscale将24位RGB输入位图转换为YUV2。 The encoder, supposedly, only takes YUV2 as input? 据推测,编码器只接受YUV2作为输入? Is this true? 这是真的? If so, how do I build libswscale for the x264 static library? 如果是这样,我如何为x264静态库构建libswscale?

1) Yes. 1)是的。 x264 includes the automatically. x264自动包含。 Its an SEI slice, and you can throw it away if you want. 它是一个SEI切片,如果你愿意,你可以扔掉它。

2) set i_slice_max_size = 1390 2)设置i_slice_max_size = 1390

3) Take a look at x264_param_t in x264.h. 3)看一下x264.h中的x264_param_t. The settings are fairly self explanatory. 这些设置相当自我解释。 As for setting the profile and preset call int x264_param_apply_profile( x264_param_t *, const char *profile ) and int x264_param_default_preset( x264_param_t *, const char *preset, const char *tune ) 至于设置配置文件和预设调用int x264_param_apply_profile( x264_param_t *, const char *profile )int x264_param_default_preset( x264_param_t *, const char *preset, const char *tune )

4) Yes, it is true, I want lying when I said that. 4)是的,这是真的,我说的时候我想说谎。 Look online/on stack overflow there are a million resources on compiling ffmpeg. 在线查看堆栈溢出,在编译ffmpeg时有一百万个资源。 In fact if you compiled x264 with avcodec support you already have it on your system. 事实上,如果您使用avcodec支持编译x264,那么您已经在系统上使用了它。

5) Yes!, you should be a good stack overflow citizen and up vote and accept answers form people who donate there free time and knowledge (which takes years to acquire) to helping you. 5)是的!,你应该是一个好的堆栈溢出公民和投票,并接受答复形式的人捐赠那里的空闲时间和知识(需要数年才能获得)来帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM