<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="arial, helvetica, sans-serif">I am trying to use videotoolbox to encode yuv frames for macOS. I am able to find the appropriate device and successfully create <span style="color:rgb(0,0,0)">AVHWFramesContext. B</span>ut when trying to call</font> <span style="color:rgb(0,0,0);font-family:Menlo;font-size:12px">av_hwframe_get_buffer, </span><font face="arial, helvetica, sans-serif"><span style="color:rgb(0,0,0)">I always get the error (</span><span style="color:rgb(0,0,0)">AVERROR(EINVAL)) </span></font><span style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">because my </span><span style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">AVHWFramesContext</span><span style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)"> pool is NULL.</span></div><div><font face="arial, helvetica, sans-serif"><span style="color:rgb(0,0,0)"><br></span></font></div><div><span style="color:rgb(0,0,0)"><font face="arial, helvetica, sans-serif">Here is code to create device context:</font></span></div><div><span style="color:rgb(0,0,0)"><font face="arial, helvetica, sans-serif"><br></font></span></div><div><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">ret = av_hwdevice_ctx_create(&deviceCtx_, hwType, <span style="color:rgb(0,0,255)">nullptr</span>, <span style="color:rgb(0,0,255)">nullptr</span>, 0);</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">And to create frame context:</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">framesCtx_ = av_hwframe_ctx_alloc(deviceCtx_);</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(0,0,255)">if</span> (!framesCtx_)</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo"><font color="#000000"><span style="caret-color: rgb(0, 0, 0);">    </span></font><span style="color:rgb(0,0,255)">return<span style="color:rgb(0,0,0)"> </span>false<span style="color:rgb(0,0,0)">;</span></span></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Helvetica;min-height:14px"><br></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"> AVHWFramesContext *ctx = (AVHWFramesContext*)(framesCtx_->data);</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"> ctx->format = format_;</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"> ctx->sw_format = swFormat_;</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"> ctx->width = width;</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"> ctx->height = height;</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,128,0)"><br></p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"> <span style="color:rgb(0,0,255)">if</span> ((ret = av_hwframe_ctx_init(framesCtx_)) < 0)</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">











</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">     av_buffer_unref(&framesCtx_);</p><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br></p><p style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-family:Menlo;font-size:12px;color:rgb(0,0,0)">Do I need to </span><font face="arial, helvetica, sans-serif" style="background-color:rgb(255,255,255)" color="#000000">set the initial pool size when using videotoolbox? If I do, I get error when calling</font><font face="Menlo" style="color:rgb(0,128,0);font-size:12px"> </font><span style="color:rgb(0,0,0);font-family:Menlo;font-size:12px">av_hwframe_ctx_init. In this case, the </span><font color="#000000" face="Menlo"><span style="font-size:12px">internal pool is NULL.</span></font></p><p style="margin:0px;font-stretch:normal;line-height:normal"><font color="#000000" face="Menlo"><span style="font-size:12px">Do I need to manage the context pool myself or should it be done automatically?</span></font></p></div></div></div></div></div></div></div></div></div></div></div></div>