Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scale error code:870, mean:Error number 870 occurred #11

Open
jiayugang opened this issue Jun 7, 2023 · 1 comment
Open

scale error code:870, mean:Error number 870 occurred #11

jiayugang opened this issue Jun 7, 2023 · 1 comment

Comments

@jiayugang
Copy link

你好,我这边使用glReadPixels抓取的一帧数据,
int width = 1920;
int height = 870;
int frameRate = 60;
int fmt_size = sizeof(unsigned char) * 4;
int row_size = width * fmt_size;
int bufferSize = width * height * fmt_size * 2;
HANDLE hEvent;
unsigned char *_data;
unsigned char *_tmpdata = new unsigned char[bufferSize];
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE /0x8035/,
_tmpdata);
for (int i = 0; i < height; i++) {
memcpy(&_data[i * row_size], &_tmpdata[(height - i - 1) * row_size],
row_size);
}

	EncoderManager::getInstance().encode(_tmpdata, width, height);

先进行转换YUV, scale时报错了。 传入的宽高是一个固定的值: 1920*870, 帮给看看

AVFrame *EncoderManager::toAVFrame(unsigned char *data, int width, int height) {
AVFrame *avFrame = av_frame_alloc();

av_image_alloc(avFrame->data, avFrame->linesize, width,
height, encoder->getCodecContext()->pix_fmt, 1);

std::int32_t row_pitch {};
row_pitch = width * 4;
const int linessizes[2] {
row_pitch, 0
};
const uint8_t *tmp[2] = { (uint8_t *)data, NULL };
SwsContext *sws = sws_getContext(width, height, AV_PIX_FMT_RGBA, width, height,
AV_PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
int ret = sws_scale(sws, tmp, linessizes, 0, encoder->getCodecContext()->height,
avFrame->data, avFrame->linesize);
printfString("toAVFrame scale", ret);
return avFrame;
}

EncoderManager::encode:1920, 870
toAVFrame scale error code:870, mean:Error number 870 occurred
encode sw
MediaCodec::queueInputToEncoder::error input to encoder
queueInputToEncoder result error code:-1, mean:Operation not permitted
EncoderManager::run:frameCount:1

@githubhaohao
Copy link
Owner

bufferSIze 看着不对

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants