ffmpeg入门之 Tutorial02 分类: ffmpeg-SDL-VLC-Live555 2013-08-26 08:48 520人阅读 评论(0) 收藏

02实际是在01的基础上添加了 SDL显示yuv部分,这部分相对独立。

  if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER))
  {
    fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
    exit(1);
  }

 

screen = SDL_SetVideoMode(pCodecCtx->width, pCodecCtx->height, 0, 0);

  
  // Allocate a place to put our YUV image on that screen
  bmp = SDL_CreateYUVOverlay(pCodecCtx->width,
     pCodecCtx->height,
     SDL_YV12_OVERLAY,
     screen);

 

 SDL_LockYUVOverlay(bmp);

 pict.data[0] = bmp->pixels[0];
 pict.data[1] = bmp->pixels[2];
 pict.data[2] = bmp->pixels[1];

 SDL_UnlockYUVOverlay(bmp);
 
 rect.x = 0;
 rect.y = 0;
 rect.w = pCodecCtx->width;
 rect.h = pCodecCtx->height;


 SDL_DisplayYUVOverlay(bmp, &rect);

 

 

    SDL_PollEvent(&event);
    switch(event.type)
 {
    case SDL_QUIT:
      SDL_Quit();
      exit(0);
      break;
    default:
      break;
    }
 SDL_Delay(40);

版权声明:本文为博主原创文章,未经博主允许不得转载。

posted @ 2013-08-26 08:48  毛毛虫的薄刻  阅读(136)  评论(0编辑  收藏  举报