Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void RipHttp::run(const char *url) {
- AVFormatContext *pFormatCtx;
- // open input and figure out what file format it is
- if(avformat_open_input(&pFormatCtx, url, NULL, NULL) != 0) {
- fprintf(stderr, "Could not open %s\n", url);
- return;
- }
- // find info about the streams it contains
- if(av_find_stream_info(pFormatCtx) < 0) {
- av_dump_format(pFormatCtx, 0, url, 0);
- return;
- }
- // find audio stream
- // int audioStream = 1;
- int i = 0;
- /* int num_streams = pFormatCtx->nb_streams;
- std::cout << num_streams;
- for(i = 0; i < num_streams; i++) {
- if(pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- audioStream = i;
- break;
- }
- }
- if(audioStream == -1) {
- fprintf(stderr, "Could not find audio stream in %s\n", url);
- return;
- }
- AVCodecContext *pCodecCtx = NULL;
- pCodecCtx = pFormatCtx->streams[audioStream]->codec;
- // find codec
- AVCodec *pCodec;
- pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
- if(pCodec == NULL) {
- fprintf(stderr, "Codec not found for %s\n", url);
- return;
- }
- // open codec
- if(avcodec_open(pCodecCtx, pCodec) < 0) {
- fprintf(stderr, "Could not open codec for %s\n", url);
- return;
- }*/
- std::cout << "Done!\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement