流式输出x264_encoder_encode

时间:2013-09-18 11:08:26

标签: c++ udp streaming x264 libx264

如何通过UDP流式传输x264_encoder_encode的输出?

这是我的Init_x264功能:

x264_param_t param;
x264_param_default_preset(&param, "veryfast", "zerolatency");
param.i_threads = 1;
param.i_width = width;
param.i_height = height;
param.i_fps_num = 30;
param.i_fps_den = 1;

param.i_keyint_max = 30;
param.b_intra_refresh = 1;

param.rc.i_rc_method = X264_RC_CRF;
param.rc.f_rf_constant = 25;
param.rc.f_rf_constant_max = 35;

param.b_annexb = 1;
param.b_repeat_headers = 1;

param.i_log_level = X264_LOG_DEBUG;

x264_param_apply_profile(&param, "baseline");

encoder = x264_encoder_open(&param);

picIn = new x264_picture_t;
picOut = new x264_picture_t;
x264_picture_alloc(picIn, X264_CSP_I420, width, height);
x264_encoder_parameters(encoder, &param);

现在不是将x264_encoder_encode的输出保存到磁盘(使用fwrite),而是尝试通过UDP将其发送到目的地。我尝试用avplay播放它,但它失败了:

[h264 @ 0x7f83f0012e80] non-existing PPS 0 referenced
[h264 @ 0x7f83f0012e80] decode_slice_header error
[h264 @ 0x7f83f0012e80] no frame!
[h264 @ 0x7f83f0012e80] non-existing PPS 0 referenced
[h264 @ 0x7f83f0012e80] decode_slice_header error
[h264 @ 0x7f83f0012e80] no frame!

使用vlc,我收到了不同的错误消息,主要是关于缺少标题。

0 个答案:

没有答案