HydrogenAudio

Lossy Audio Compression => Ogg Vorbis => Ogg Vorbis - Tech => Topic started by: JenyaKh on 2013-10-21 07:33:39

Title: ogg vorbis encoding problem
Post by: JenyaKh on 2013-10-21 07:33:39
Hello, everybody! Could you help me, please?
I had a simple ogg file (about 2 seconds-length). I converted it just to a pcm file using "libvorbisfile". Then I tried to convert it to .ogg again.
So, first I used libvorbisenc to setup encoding. I took that pcm file that I had got after decoding and wrote each its 2 consequent bytes in short and then just transformed them to float:
            short integerSample;
            ((char *)(&integerSample))[0] = pcmData[(i + j) * 2];
            ((char *)(&integerSample))[1] = pcmData[(i + j) * 2 + 1];
            inputEncodingBuffer[j] = (float)integerSample;
Then I used libvorbis to encode these raw packets to ogg pages using ogg_stream_packetin() and ogg_stream_pageout(). (I also didn't forgot about three header packets at the beginning and also created ogg pages for them.) Then I output these ogg pages using fwrite() and got an ogg file of appropriate size. I tried to play it with VLC player. But it all failed. The player recognizes this file as ogg but does not play it. And when I look at file's properties all fileds like sapling rate, channel number are equal to zeros or no info. So I understand that i do something wrong. But i can't understand what exactly. I read all info on ogg vorbis official site. Looked through great deal of similar codes in the Interenet. But it seems like I didn't forgot anything. So I don't understand why my code does not work. By the way, when I change some parametres in vorbis_encode_init_vbr(), e.g. sampling rate or quality my output ogg files change. So this info about my music file affects encoding generally.
I understand that it's difficult to guess what's wrong only from what I've just written here. But maybe you could give me some hint.
I can write here more details about my workflow of course.
Every help will be very appreciated!
Thank you.