閱讀349 返回首頁    go 阿裏雲 go 技術社區[雲棲]


ffmpeg入門之 Tutorial02

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);

最後更新:2017-04-03 16:49:00

  上一篇:go hdu 4699 Editor 模擬
  下一篇:go 麵試題:數組匹配