I changed it to rb ( however it's right, it didn't change the result
at this point )
I tracked the data and wrote it to another file to check what's going
on. But i still get the same result.
ByteIOContext is still free..
int read_data(void *opaque, uint8_t *buf, int buf_size){
int static zozo=0;
zozo++;
FILE * fp = (FILE *) opaque;
if(!fp){
return -1;
}
int cnt = fread(buf, sizeof(uint8_t), buf_size, fp);
NSLog(@"cnt: %d",cnt);
if(zozo==1){
FILE *zp=fopen("firsttest.txt", "w+b");
fwrite(buf,cnt,1,zp);
fclose(zp);
}
if(zozo==2){
FILE *zp=fopen("secondtest.txt", "w+b");
fwrite(buf,cnt,1,zp);
fclose(zp);
}
return cnt;
}
2009/7/20 avcoder <[email protected]>:
> try :
>
> FILE * fp = fopen("79.wma", "rb");
>
> On Mon, Jul 20, 2009 at 2:16 AM, jacob jacob<[email protected]> wrote:
>> /*
>>
>> 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
>>
>
>
>
> --
> -----------------------------------------------------------------------------------------
> My key fingerprint: d1:03:f5:32:26:ff:d7:3c:e4:42:e3:51:ec:92:78:b2
> Inspired by http://www.nextplayer.net. Your potential. Our passion.
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user