91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 11.04MB
    文件類型: .7z
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2024-01-30
  • 語言: 其他
  • 標(biāo)簽: ffmpeg??播放器??

資源簡介

FFMPEG工程浩大,可以參考的書籍又不是很多,因此很多剛學(xué)習(xí)FFMPEG的人常常感覺到無從下手。 該播放器代碼十分簡單,只有約100行左右。但是幾乎包含了使用FFMPEG播放一個視頻所有必備的API,并且使用SDL顯示解碼出來的視頻。十分適合新手學(xué)習(xí)FFmpeg。 使用了2014.5.6編譯的類庫,支持最新的HEVC以及VP9.

資源截圖

代碼片段和文件信息

/*?
?*最簡單的基于FFmpeg的播放器
?*Simplest?FFmpeg?Player
?*
?*雷霄驊?Lei?Xiaohua
?*leixiaohua1020@126.com
?*中國傳媒大學(xué)/數(shù)字電視技術(shù)
?*Communication?University?of?China?/?Digital?TV?Technology
?*http://blog.csdn.net/leixiaohua1020
?*
?*本程序?qū)崿F(xiàn)了視頻的解碼和播放。
?*支持最新的HEVC和VP9
?*/


#include?“stdafx.h“

int?_tmain(int?argc?_TCHAR*?argv[])
{
AVFormatContext *pFormatCtx;
int i?videoindex;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
char?filepath[]=“src01_480x272.vp9“;
//char?filepath[]=“cuc_ieschool1.flv“;
//char?filepath[]=“src01_480x272_22.hm10“;
av_register_all();
avformat_network_init();
pFormatCtx?=?avformat_alloc_context();

if(avformat_open_input(&pFormatCtxfilepathNULLNULL)!=0){
printf(“Couldn‘t?open?input?stream.(無法打開輸入流)\n“);
return?-1;
}
if(av_find_stream_info(pFormatCtx)<0)
{
printf(“Couldn‘t?find?stream?information.(無法獲取流信息)\n“);
return?-1;
}
videoindex=-1;
for(i=0;?inb_streams;?i++)?
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
{
videoindex=i;
break;
}
if(videoindex==-1)
{
printf(“Didn‘t?find?a?video?stream.(沒有找到視頻流)\n“);
return?-1;
}
pCodecCtx=pFormatCtx->streams[videoindex]->codec;
pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
if(pCodec==NULL)
{
printf(“Codec?not?found.(沒有找到解碼器)\n“);
return?-1;
}
if(avcodec_open2(pCodecCtx?pCodecNULL)<0)
{
printf(“Could?not?open?codec.(無法打開解碼器)\n“);
return?-1;
}
AVframe *pframe*pframeYUV;
pframe=avcodec_alloc_frame();
pframeYUV=avcodec_alloc_frame();
uint8_t?*out_buffer;
out_buffer=new?uint8_t[avpicture_get_size(PIX_FMT_YUV420P?pCodecCtx->width?pCodecCtx->height)];
avpicture_fill((AVPicture?*)pframeYUV?out_buffer?PIX_FMT_YUV420P?pCodecCtx->width?pCodecCtx->height);
//------------SDL----------------
if(SDL_Init(SDL_INIT_VIDEO?|?SDL_INIT_AUDIO?|?SDL_INIT_TIMER))?{??
printf(?“Could?not?initialize?SDL?-?%s\n“?SDL_GetError());?
return?-1;
}?
SDL_Surface?*screen;?
screen?=?SDL_SetVideoMode(pCodecCtx->width?pCodecCtx->height?0?0);
if(!screen)?{??
printf(“SDL:?could?not?set?video?mode?-?exiting\n“);??
return?-1;
}
SDL_Overlay?*bmp;?
bmp?=?SDL_CreateYUVOverlay(pCodecCtx->width?pCodecCtx->heightSDL_YV12_OVERLAY?screen);?
SDL_Rect?rect;
//---------------
int?ret?got_picture;
int?y_size?=?pCodecCtx->width?*?pCodecCtx->height;

AVPacket?*packet=(AVPacket?*)av_malloc(sizeof(AVPacket));
av_new_packet(packet?y_size);
//輸出一下信息-----------------------------
printf(“File?Information(文件信息)---------------------\n“);
av_dump_format(pFormatCtx0filepath0);
printf(“-------------------------------------------------\n“);
struct?SwsContext?*img_convert_ctx;
img_convert_ctx?=?sws_getContext(pCodecCtx->width?pCodecCtx->height?pCodecCtx->pix_fmt?pCodecCtx->width?pCodecCtx->height?PIX_FMT_YUV420P?SWS_BICUBIC?NULL?NULL?NULL);?
//------------------------------
while(av_read_frame(pFormatCtx?packet)>=

評論

共有 條評論