Am presently trying to convert a wave file to mp3 using LAME (which I have succeeded in doing). I also tried writing the id3tag to the mp3 which had been a success up to the point of id3tag_set_albumart
.
Going through the parse.c
in the frontend folder, I discovered that the second parameter of id3tag_set_albumart
(image) will be the content of the image file while the third parameter will be the size of the image file.
But when I did this (code below), it return 0 which according to the lame.h is success but the encoding refuse to take place (i.e. The wave file converting to mp3).
FILE* fpi = 0;
char *albumart = 0;
char *filename = "ty.jpg";
fpi = fopen(filename, "rb");
size_t size;
fseek(fpi, 0, SEEK_END);
size = ftell(fpi);
fseek(fpi, 0, SEEK_SET);
albumart = (char*)malloc(size);
fread(albumart, 1, size, fpi);
id3tag_set_albumart(lame, albumart, size);
free(albumart);
fclose(fpi);
EDIT: when ever I call id3tag_set_albumart, lame_encode_buffer_interleaved returns -1 which according to lame.h means mp3buf was too small. I dont think this as to do with the "size of the array" because I increased it to twice it present size but the function still returns -1