QT开发中文网

while (true) { Mat img; cap.read(img); if (!img.empty()) { imshow("video", img); // 将 OpenCV 中的 Mat 转换为 FFmpeg 中的 AVFrame cvtColor(img, img, COLOR_BGR2RGB);

This code continuously reads frames from a video file using OpenCV’s VideoCapture class in a loop. If the frame is not empty, it is displayed in a window using imshow() and then converted to an AVFrame that can be used by FFmpeg. The converted frame is then encoded using avcodec_encode_video2() function and written to an output file using av_interleaved_write_frame(). If there are any errors during encoding, the loop breaks and the program exits.

The loop also checks for user input to quit the program by checking if the ‘q’ key has been pressed using waitKey(). If the key has been pressed, the loop breaks and the program exits.

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://qt.0voice.com/?id=2114

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?