Video beaglebone black支持gpu硬件加速吗?
提前谢谢。 我正试着在德州仪器公司生产的beaglebone black(BBB)上播放视频。 因为有很多关于使用ffmpeg和SDL的好教程,所以我决定使用它。 获取有关视频和编解码器的信息,使用ffmpeg解码帧。 使用SDL显示解码帧以进行监控 我使用的是SDL2,它使用渲染器、纹理将图像显示到屏幕上。 根据SDL wiki,渲染器使用GPU加速。 但这里有个问题。视频播放太慢。。。大约0.5fps 所以我转向使用软件渲染的SDL1.2。 它通过CPU RAM显示yuv覆盖 我想也许BBB不支持GPU加速,在谷歌上搜索了一下,但没有得到答案。需要帮忙吗? 这是我使用SDL2的代码Video beaglebone black支持gpu硬件加速吗?,video,sdl-2,beagleboneblack,hardware-acceleration,Video,Sdl 2,Beagleboneblack,Hardware Acceleration,提前谢谢。 我正试着在德州仪器公司生产的beaglebone black(BBB)上播放视频。 因为有很多关于使用ffmpeg和SDL的好教程,所以我决定使用它。 获取有关视频和编解码器的信息,使用ffmpeg解码帧。 使用SDL显示解码帧以进行监控 我使用的是SDL2,它使用渲染器、纹理将图像显示到屏幕上。 根据SDL wiki,渲染器使用GPU加速。 但这里有个问题。视频播放太慢。。。大约0.5fps 所以我转向使用软件渲染的SDL1.2。 它通过CPU RAM显示yuv覆盖 我想也许BBB
#include <libavutil/frame.h>
#include <libavutil/avutil.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_thread.h>
#ifdef __MINGW32__
#undef main /* Prevents SDL from overriding main() */
#endif
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <errno.h>
int main(int argc, char *argv[]) {
AVFormatContext *pFormatCtx = NULL;
int i, videoStream;
AVCodecContext *pCodecCtx = NULL;
AVCodec *pCodec = NULL;
AVFrame *pFrame = NULL;
AVPacket packet;
int frameFinished;
SDL_Window *window=NULL;
SDL_Renderer *renderer=NULL;
SDL_Texture *bmp=NULL;
SDL_Event event;
int fbfd, ret;
struct fb_var_screeninfo fbvar;
if(argc < 2) {
fprintf(stderr, "Usage: test <file>\n");
exit(1);
}
// Register all formats and codecs
av_register_all();
if(SDL_Init(SDL_INIT_VIDEO)) {
fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
exit(1);
}
// Open video file
if(avformat_open_input(&pFormatCtx, argv[1], NULL, NULL)!=0)
return -1; // Couldn't open file
// Retrieve stream information
if(avformat_find_stream_info(pFormatCtx, NULL)<0)
return -1; // Couldn't find stream information
// Dump information about file onto standard error
av_dump_format(pFormatCtx, 0, argv[1], 0);
// Find the first video stream
videoStream=-1;
for(i=0; i<pFormatCtx->nb_streams; i++)
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
videoStream=i;
break;
}
if(videoStream==-1)
return -1; // Didn't find a video stream
// Get a pointer to the codec context for the video stream
pCodecCtx=pFormatCtx->streams[videoStream]->codec;
// Find the decoder for the video stream
pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
if(pCodec==NULL) {
fprintf(stderr, "Unsupported codec!\n");
return -1; // Codec not found
}
// Open codec
if( avcodec_open2(pCodecCtx, pCodec, NULL)<0 )
return -1; // Could not open codec
// Allocate video frame
pFrame=av_frame_alloc();
int ctxW= pCodecCtx->width;
int ctxH= pCodecCtx->height;
window =
SDL_CreateWindow("test",
SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED, 0, 0,
SDL_WINDOW_BORDERLESS SDL_WINDOW_FULLSCREEN_DESKTOP);
renderer = SDL_CreateRenderer(window, -1, 0);
// Allocate a place to put our YUV image on that screen
bmp = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING,
pCodecCtx->width, pCodecCtx->height);
av_init_packet(&packet);
// Read frames and save first five frames to disk
while(av_read_frame(pFormatCtx, &packet)>=0) {
// Is this a packet from the video stream?
if(packet.stream_index==videoStream) {
// Decode video frame
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
// Did we get a video frame?
if(frameFinished) {
SDL_UpdateYUVTexture(bmp, NULL, pFrame->data[0], pFrame->linesize[0],
pFrame->data[1], pFrame->linesize[1],
pFrame->data[2], pFrame->linesize[2]);
}
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, bmp, NULL, NULL);
SDL_RenderPresent(renderer);
}
SDL_Delay(15);
SDL_PollEvent(&event);
switch(event.type) {
case SDL_QUIT:
SDL_Quit();
exit(0);
break;
default:
break;
}
}
// Free the packet that was allocated by av_read_frame
av_free_packet(&packet);
// Free the YUV frame
av_frame_free(&pFrame);
// Close the codec
avcodec_close(pCodecCtx);
// Close the video file
avformat_close_input(&pFormatCtx);
return 0;
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#ifdef_uumingw32__
#undef main/*防止SDL重写main()*/
#恩迪夫
#包括
#包括
#包括
#包括
#包括
#包括
int main(int argc,char*argv[]){
AVFormatContext*pFormatCtx=NULL;
inti,视频流;
AVCodecContext*pCodecCtx=NULL;
AVCodec*pCodec=NULL;
AVFrame*pFrame=NULL;
数据包;
int框架完成;
SDL_Window*Window=NULL;
SDL_渲染器*渲染器=NULL;
SDL_纹理*bmp=NULL;
SDL_事件;
int fbfd,ret;
结构fb_var_屏幕信息fbvar;
如果(argc<2){
fprintf(stderr,“用法:测试”);
出口(1);
}
//注册所有格式和编解码器
av_寄存器_all();
中频(SDL_初始化(SDL_初始化视频)){
fprintf(stderr,“无法初始化SDL-%s\n”,SDL_GetError());
出口(1);
}
//打开视频文件
if(avformat\u open\u输入(&pFormatCtx,argv[1],NULL,NULL)!=0)
return-1;//无法打开文件
//检索流信息
if(avformat_find_stream_info(pFormatCtx,NULL)streams[videoStream]->编解码器;
//查找视频流的解码器
pCodec=avcodec\u find\u解码器(pCodecCtx->codec\u id);
if(pCodec==NULL){
fprintf(stderr,“不支持的编解码器!\n”);
return-1;//找不到编解码器
}
//开放式编解码器
if(avcodec_open2(pCodecCtx,pCodec,NULL)宽度;
int-ctxH=pCodecCtx->height;
窗口=
SDL_CreateWindow(“测试”,
SDL_WINDOWPOS_未定义,SDL_WINDOWPOS_未定义,0,0,
SDL_窗口(无边框)SDL_窗口(全屏)(桌面);;
渲染器=SDL_CreateRenderer(窗口,-1,0);
//分配一个位置将我们的YUV图像放在该屏幕上
bmp=SDL_CreateTexture(渲染器,
SDL_像素格式_YV12,SDL_纹理访问_流媒体,
PCODECTX->宽度,PCODECTX->高度);
av_初始_数据包(&数据包);
//读取帧并将前五帧保存到磁盘
而(av_读取_帧(pFormatCtx和数据包)>=0){
//这是来自视频流的数据包吗?
if(数据包流\索引==视频流){
//解码视频帧
avcodec_decode_video2(pCodecCtx、pFrame、frameFinished和packet);
//我们有录像带吗?
如果(框架完成){
SDL_UpdateYouvTexture(bmp,NULL,pFrame->data[0],pFrame->linesize[0],
pFrame->数据[1],pFrame->线宽[1],
pFrame->data[2],pFrame->linesize[2]);
}
SDL_渲染器(渲染器);
SDL_渲染复制(渲染器,bmp,NULL,NULL);
SDL_渲染器呈现(渲染器);
}
SDL_延迟(15);
SDL_PollEvent(事件和事件);
开关(事件类型){
案例SDL_退出:
SDL_退出();
出口(0);
打破
违约:
打破
}
}
//释放av_read_帧分配的数据包
av_免费_数据包(&数据包);
//释放YUV框架
无av帧(&pFrame);
//关闭编解码器
avcodec_关闭(PCODECTX);
//关闭视频文件
avformat_close_输入(&P格式发送);
返回0;
}
是的,beaglebone black支持gpu硬件加速
从这个维基百科链接
BBB有PowerVR SGX530GPU,其详细信息可在此处找到
这个来自BBB官方网站
处理器:AM335x 1GHz ARM®Cortex-A8
512MB DDR3 RAM
4GB 8位eMMC板载闪存
3D图形加速器
氖浮点加速器
2x PRU 32位微控制器
你也可以查一下
裁判:
BBONEBLK_SRM BeagleBone黑色系统
参考手册
Rev A5.2您知道提供的任何图像是否有驱动程序支持,以便openGL应用程序可以使用它吗?