int main(int argc,char**argv) { // win_x11_init_vdpau_procs(); int fd=creat("out.yuv",0666); if(fd<0){ fprintf(stderr,"Create yuv file Failed..\n"); return 0; } int ret; av_register_all(); avformat_network_init(); // fmtctx=NULL; ret=avformat_open_input(&fmtctx,argv[1],NULL,NULL); if(ret<0){ fprintf(stderr,"avformat_open_input() failed..\n"); return -1; } ret=avformat_find_stream_info(fmtctx,NULL); if(ret<0){ fprintf(stderr,"avformat_find_stream_info() failed..\n"); return -1; } av_dump_format(fmtctx,0,argv[1],0); ret=av_find_best_stream(fmtctx,AVMEDIA_TYPE_VIDEO,-1,-1,NULL,0); if(ret<0){ fprintf(stderr,"av_find_best_stream() failed..\n"); return -3; } vst=ret; st=fmtctx->streams[ret]; decctx=st->codec; #if 0 /* dec=avcodec_find_decoder_by_name("h264_vdpau"); if(!dec){ fprintf(stderr,"avcodec_find_decoder_by_name() failed..\n"); return -4; } */ decctx->opaque=&vd; dec=vd.openCodec(decctx); #else decctx->opaque=&vc; dec=vc.open_vdpau_codec(decctx); #endif ret=avcodec_open2(decctx,dec,NULL); if(ret<0){ fprintf(stderr,"avcodec_open2() failed..\n"); return -5; } // vc.make_decoder(decctx); AVPacket pkt; av_init_packet(&pkt); AVPicture p; AVFrame*frame=NULL; int got=0; int i=0; frame=av_frame_alloc(); while(av_read_frame(fmtctx,&pkt)>=0){ if(pkt.stream_index!=vst){ continue; } ret=avcodec_decode_video2(decctx,frame,&got,&pkt); if(ret<0){ fprintf(stderr,"avcodec_decode() failed..\n"); return -5; } if(got){ vdpau_render_state*rs=(vdpau_render_state*)frame->data[0]; fprintf(stderr,"Frame <%d> Got..\n",i); i++; vc.fetch_yuv(rs,&p); if(i<200) write_avpicture(&p,fd); release_vdpau_render_state(rs); }else{ fprintf(stderr,"Wait Frame..\n"); } } close(fd); // sleep(10000); return 0; }