Hello Everyone,

I am new to ffmpeg and I am working on AAC encoder, I tried encoding the pcm 
sample having f32le sample format but whatever the pcm sample format i am 
having is  s32le so i need to convert it to f32le,I tried with ffmpeg's 
resampling_audio.c example and i have modified the code to take pcm file as 
input.. but the output file size is always ~=11000 bytes and it is not playing

Also i tried with very the following code but swr_convert() is returning -22 
and i am not sure what ever code i got/written is correct...

Here is the sample code i am trying currently

int main(int argc, char **argv)
{
uint8_t *dst,*dstp;
uint8_t *outbuf;
int ret;
size_t bufsize;
FILE *fp=NULL;
FILE *fout=NULL;
struct SwrContext *ctx = NULL;
char *filename=argv[1];
fp = fopen("FLTP1.pcm","rb");
fout = fopen(filename,"wb");

if (fseek(fp, 0L, SEEK_END) == 0)
    bufsize=ftell(fp);

fseek(fp, 0L, SEEK_SET);

printf(" buf size is %d\n",bufsize);
dstp=( uint8_t *)malloc(sizeof(uint8_t) * (bufsize + 1));
outbuf=( uint8_t *)malloc(sizeof(uint32_t) * (bufsize*1000 + 1));
dstp=dst;
while(!feof(fp))
{
printf(" reading samples from file\n");
    ret=fread(&dstp,1,4,fp);
dst++;
printf(" return value is %d\n",ret);
}
//dst=dstp;





ctx = swr_alloc_set_opts(ctx,AV_CH_LAYOUT_STEREO,AV_SAMPLE_FMT_S32,48000,
                                         
AV_CH_LAYOUT_STEREO,AV_SAMPLE_FMT_FLTP,44100,0,0);
if(swr_init(ctx) < 0)
     return -1;


printf(" converting\n");

int  resample_samples = swr_convert(ctx,(uint8_t**)&outbuf,bufsize*1000,
                                         (const uint8_t**)&dst,bufsize);
printf(" return value is %d\n",resample_samples);
printf(" writing to file\n");

fwrite(outbuf,resample_samples,1,fout);

printf(" wrote to file\n");


//free(&outbuf);
//free(&dstp);

swr_free(&ctx);

return 0;

}

It will be of great help to me  if you provide me with any suggestions/help

Thanks in advance

Best regards

Haridas Sagar N


Notice: The information contained in this e-mail message and/or attachments to 
it may contain confidential or privileged information. If you are not the 
intended recipient, any dissemination, use, review, distribution, printing or 
copying of the information contained in this e-mail message and/or attachments 
to it are strictly prohibited. If you have received this communication in 
error, please notify us by reply e-mail or telephone and immediately and 
permanently delete the message and any attachments. Thank you

_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to