/*

i have a problem related to av_open_input_stream usage.
it returns -1 and when i trace it in detail, read_header in asf.c returns -1
when comparing headers (GUID information).

it seems like my ByteIOContext is empty..

i don't know why..

*/

int read_data(void *opaque, uint8_t *buf, int buf_size){

        printf("it is here. buf_size. %d",buf_size);
        

        FILE * fp = (FILE *) opaque;
        if (!fp)
        {
                return -1;
        }
        
        int cnt = fread(buf, sizeof(uint8_t), buf_size, fp);

        return cnt;

}

void doit(){

        FILE * fp = fopen("79.wma", "r");
        

        

                
        avcodec_init();
        avcodec_register_all();
        av_register_all();

        
        
        
        
        
        uint8_t pDataBuffer[2048];
        long lSize = 2048;
        
        read_data(fp, pDataBuffer, lSize);

        
        AVProbeData pd;
        pd.buf = pDataBuffer;
        pd.buf_size = lSize;
        pd.filename = "";
        
        AVInputFormat* pAVInputFormat = av_probe_input_format(&pd, 1);
        if(!pAVInputFormat)
        {
                printf("something 0");
                return;
        }
        pAVInputFormat->flags |= AVFMT_NOFILE;
        
        ByteIOContext ByteIOCtx;
        if(init_put_byte(&ByteIOCtx, pDataBuffer, lSize, 0, fp, read_data,
NULL, NULL) < 0)
        {
                printf("something 1");
                return ;
        }
        
        AVFormatContext* pFormatCtx;
        
        
        if(av_open_input_stream(&pFormatCtx, &ByteIOCtx, "", pAVInputFormat,
NULL) < 0)
        {
                printf("something 2");
                return ;
        }
        
        if(av_find_stream_info(pFormatCtx) < 0)
        {
                printf("something 3");
                return ;
        }

printf("something 4");
        
}
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to