现在的位置: 首页 > 综合 > 正文

iphone ffmpeg h264

2013年06月23日 ⁄ 综合 ⁄ 共 688字 ⁄ 字号 评论关闭

参考:http://www.rosoo.net/a/201006/9659.html

 

  1. Decode() 
  2. FILE * inpf; 
  3.  
  4. int nWrite; 
  5. int i,p; 
  6. int nalLen; 
  7. unsigned char* Buf; 
  8. int got_picture, consumed_bytes; 
  9. unsigned char *DisplayBuf; 
  10. DisplayBuf=(unsigned char *)malloc(60000); 
  11.  
  12. char outfile[] = "test.pgm"
  13.  
  14. //1.打开输入文件 
  15. inpf = fopen("test.264""rb"); 
  16.  
  17. //outf = fopen("out.yuv", "wb"); 
  18.  
  19. if(!inpf) 
  20. goto Decodereturn; 
  21.  
  22. nalLen = 0; 
  23. Buf = (unsigned char*)calloc ( 1000000, sizeof(char)); //准备解码文件缓冲 
  24.  
  25. //2.注册解码器,并且找到H264解码器 
  26. avcodec_init(); 
  27. avcodec_register_all(); 
  28. codec = avcodec_find_decoder(CODEC_ID_H264); 
  29.  
  30. if (!codec) { 
  31. return 0; 
  32. //allocate codec context 
  33. //分配解码器内存 
  34. c = avcodec_alloc_context(); 
  35.  
  36. if(!c){ 
  37. return 0; 
  38. //open codec 
  39. //3.打开解码器 

抱歉!评论已关闭.