rockcarry / fanplayer

A portable video player based on ffmpeg for windows and android platform.
GNU Lesser General Public License v3.0
606 stars 161 forks source link

硬解情况下如何截图 #46

Closed zslovelq closed 3 years ago

zslovelq commented 3 years ago

snapshot.c里面的代码
// scale picture sws_ctx = sws_getContext(video->width, video->height, video->format, picture.width, picture.height, swsofmt, SWS_FAST_BILINEAR, NULL, NULL, NULL); if (!sws_ctx) { av_log(NULL, AV_LOG_ERROR, "could not initialize the conversion context jpg\n"); goto done; } sws_ctx的值为空,video->format的值是61即 AV_PIX_FMT_DXVA2_VLD

感觉硬解的时候AVFrame *video,video->data也是空,如何保存图片?

rockcarry commented 3 years ago

这个需要特殊处理,DXVA2 硬解得到的是一个 d3d 的 surface,要从 surface 里面取数据,然后编码才行

zslovelq commented 3 years ago

QQ截图20210401154432

大神帮我看看哪里用的不对? imagedata = (uint8_t *)lockedrect.pBits; 为什么我得到的是单通道的灰度图,我看其他人用这个lockrect得到的是4通道的ARGB的图像。

zslovelq commented 3 years ago

我明白了,这个取出来的不是灰度图,代码有误。应该是YUV图,大小为1.5×宽×高的大小。

rockcarry commented 3 years ago

最新代码增加了 dxva2 硬件解码 + swscale 的渲染方式,可以支持截图功能。 你可以更新试下效果。