- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用 ffmpeg 捕获 Windows 屏幕。
一切正常,但 avcodec_receive_packet 返回错误 AVERROR(EAGAIN)
我无法理解为什么会这样。
有人可以给建议吗?
SwsContext* convertContext = sws_getContext(c->width, c->height, AV_PIX_FMT_BGRA, c->width, c->height, c->pix_fmt, SWS_FAST_BILINEAR, NULL, NULL, NULL);
for (int i = 0; i < fps*seconds; i++)
{
fflush(stdout);
/* make sure the frame data is writable */
ret = av_frame_make_writable(frame);
if (ret < 0)
exit(1);
gdi->MakeScreenshoot();
OutFrame->pts = i;
int ret = av_image_fill_arrays(GDIFrame->data, GDIFrame->linesize, gdi->m_bufferGDIBits, AV_PIX_FMT_BGRA, c->width, c->height, 1);
ret = av_image_fill_arrays(OutFrame->data, OutFrame->linesize, outbuffer, c->pix_fmt, c->width, c->height, 1);
GDIFrame->data[0] += GDIFrame->linesize[0] * (c->height - 1); // flipping frame
GDIFrame->linesize[0] *= -1;
int hslice = sws_scale(convertContext, GDIFrame->data, GDIFrame->linesize, 0, c->height,OutFrame->data, OutFrame->linesize);
/* encode the image */
encode(c, OutFrame, pkt, f);
}
static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt, FILE *outfile)
{
int ret = -1;
/* send the frame to the encoder */
/*if (frame)
printf("Send frame %3"PRId64"\n", frame->pts);*/
ret = avcodec_send_frame(enc_ctx, frame);
if (ret < 0)
{
fprintf(stderr, "Error sending a frame for encoding\n");
exit(1);
}
while (ret >= 0)
{
ret = avcodec_receive_packet(enc_ctx, pkt);
if (ret == AVERROR_EOF)
return;
if (ret == AVERROR(EAGAIN))
return;
else
if (ret < 0)
{
fprintf(stderr, "Error during encoding\n");
exit(1);
}
//printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size);
fwrite(pkt->data, 1, pkt->size, outfile);
av_packet_unref(pkt);
}
}
if (ret == AVERROR_EOF)
return;
if (ret == AVERROR(EAGAIN))
return;
else
if (ret < 0)
{
fprintf(stderr, "Error during encoding\n");
exit(1);
}
最佳答案
派对迟到了。
我也在尝试使用 encode_video.c
当编码器没有准备好完整的数据包时,似乎 avcodec_receive_packet() 将返回这些“错误”......可能下一次调用 avcodec_send_frame() 将导致完整的数据包。
所以就继续吧。
使用 NULL 帧对 avcodec_send_frame() 的最终调用将刷新最终数据包。
关于c++ - avcodec_receive_packet 中的错误(gdi screenshot + ffmpeg),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50414435/
这两个库之间有什么区别吗? 最佳答案 根据the wikipedia article on GDI : With the introduction of Windows XP, GDI was dep
我喜欢 GDI+,因为它具有高性能并且包含在 Windows XP 中。但是,它的模糊类和效果类仅在 GDI+ 1.1 中可用,后者仅随 Windows Vista 或更高版本提供。尽管微软计划很快放
我用 C# 创建了一个图像服务,它采用基础层图像 (JPG),再分层一层更透明的 PNG(32 位),然后输出最终的 JPG 图像。我试图从这个函数中挤出最后一毫秒,但我的代码在 GDI+ 中的 Dr
我正在使用顶点以及 LineTo() 和 MoveTo() 函数制作一系列三角形来表示 3D 形状。 着色/填充这些三角形的最佳方法是什么? 谢谢 最佳答案 MSDN has a sample tha
我在 Win7 系统上注意到过一个问题,以为是 DWM 错误,但在重新启动后已修复。但现在我意识到它在其他人的系统上发生(作为默认行为),并且这也是 Surface Pro 上的正常行为。 如何重现问
是否可以在用户模式下创建自定义 GDI 设备?我们的想法是创建一个设备上下文 (HDC),我们可以将其传递给不透明的组件,这样当组件调用 GDI 函数(如 TextOut)时,我们可以获得实际的文本字
我想知道是否可以枚举所有桌面可见窗口以创建它们的位图并将所有位图组合成一个以便获得桌面的完整屏幕截图? 最有可能使用 GDI/GD+,但也欢迎使用任何外部库。首选语言C\C++。 提前致谢。 最佳答案
我有一个生成元文件 (EMF) 的应用程序。它使用引用设备(又名屏幕)来呈现这些元文件,因此元文件的 DPI 会根据代码运行的机器而变化。 假设我的代码打算创建一个 8.5 x 11 英寸的元文件。
我在同时使用 GDI 和 GDI+ 进行绘图时遇到问题。页面转换——尤其是缩放——似乎在两者之间有点偏离。除了 SetViewportExt 和 SetWindowExt 之外,GDI 上下文的哪些属
我需要从应用程序中获取一个大表(300K+ 行)并且没有导出功能。经过多次不成功的尝试后,我只剩下一个复制粘贴宏,一次一行。如果有办法在绘制时获取字符串,我可以一次获取一页(40 行)。 最佳答案 如
我曾经在我的 Win7 系统上注意到一个问题,认为这是一个 DWM 错误,因为它在重新启动后得到修复。但现在我意识到它正在其他人的系统上发生(作为默认行为),这也是 Surface Pro 上的正常行
我正在寻找一些高级教程,或者可能是用 C++ 或 .NET 编写的开源应用程序,它们可以实现复杂的基于 vector 的应用程序,例如 MS Visio 或 Autocad。我需要知道的是,当用户可以
我正在使用第三方库来绘制图表。该库需要一个 HDC (GDI)。但是我的应用程序使用的是 GDI+。 Q1:这样做安全吗? void f(Gdiplus::Graphics& graphics) {
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 4年前关闭。 Improve t
对不起,如果这是题外话。如果是这样的话;请随时将其移至适当的站点。 GDI/GDI+ 如何在不使用 DirectX 或 OpenGL 等较低级别的 API 与 GPU 通信的情况下渲染到显卡(在屏幕上
我正在尝试在兼容的渲染目标上使用 Gdi 和 Direct 2D 来渲染位图。我使用 D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_GDI_COMPATIBLE 选项创建
我们目前正在将一个较旧的应用程序转换为通过 GDI+ 绘制,而不是直接使用 GDI。随着我们逐步翻译系统,有时我们需要从 Gdiplus::Graphics 对象中获取 HDC,以便允许尚未翻译的代码
我正在尝试使用 GDI+ 在屏幕上(整个屏幕,在所有其他窗口的顶部)绘图。 我已将 NULL 传递给 GetDC 以将 HDC 显示到屏幕上,然后使用它创建一个 Graphics 对象,并使用 Dra
GDI+ 非常慢,几乎完全是软件,而 GDI 是高度硬件加速的。GDI+ 是 Graphics 类在 WinForms 上使用的东西,它太慢了。 有没有人制作了 .NET GDI 库以便我们可以有速度
ASP.NET 网站随机引发此 System.Drawing-error: System.Runtime.InteropServices.ExternalException:System.Drawin
我是一名优秀的程序员,十分优秀!