Advertisement
Guest User

Untitled

a guest
May 4th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. void RipHttp::run(const char *url) {
  2. AVFormatContext *pFormatCtx;
  3.  
  4. // open input and figure out what file format it is
  5. if(avformat_open_input(&pFormatCtx, url, NULL, NULL) != 0) {
  6. fprintf(stderr, "Could not open %s\n", url);
  7. return;
  8. }
  9.  
  10. // find info about the streams it contains
  11. if(av_find_stream_info(pFormatCtx) < 0) {
  12. av_dump_format(pFormatCtx, 0, url, 0);
  13. return;
  14. }
  15.  
  16. // find audio stream
  17. // int audioStream = 1;
  18. int i = 0;
  19. /* int num_streams = pFormatCtx->nb_streams;
  20.  
  21. std::cout << num_streams;
  22.  
  23. for(i = 0; i < num_streams; i++) {
  24. if(pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
  25. audioStream = i;
  26. break;
  27. }
  28. }
  29.  
  30. if(audioStream == -1) {
  31. fprintf(stderr, "Could not find audio stream in %s\n", url);
  32. return;
  33. }
  34.  
  35. //AVCodecContext *pCodecCtx = NULL;
  36. /* AVCodecContext *pCodecCtx = avcodec_alloc_context3(NULL);
  37.  
  38. //avcodec_close(pCodecCtx);
  39. //av_free(pCodecCtx);*/
  40.  
  41. /*pCodecCtx = pFormatCtx->streams[audioStream]->codec;
  42.  
  43. // find codec
  44. AVCodec *pCodec;
  45.  
  46. pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
  47. if(pCodec == NULL) {
  48. fprintf(stderr, "Codec not found for %s\n", url);
  49. return;
  50. }
  51.  
  52. // open codec
  53. if(avcodec_open(pCodecCtx, pCodec) < 0) {
  54. fprintf(stderr, "Could not open codec for %s\n", url);
  55. return;
  56. }*/
  57.  
  58. std::cout << "Done!\n";
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement