Author Topic: Problems with prjWriteWav and VBR mp3  (Read 7003 times)

Movie Maniac

  • Guest
Problems with prjWriteWav and VBR mp3
« on: 24 Mar '03 - 12:17 »
Hi everybody.
I'm new to this world so lets's say I'm a newbye, and maybe the worst kind of!!!
Well, I've just discovered bass project and i'd like to include the writewav demo into my project (wich is completely free, it's called MMAAT and can be downloaded from moviemaniac.altervista.org) just to give the user the possibility to convert mp3 or ogg audio demuxed from avis into wav with a click.
I'm experiencing sone troubles in converting some VBR mp3. It doesn't convert the whole file, or it completes conversion but the result is shorter than the original by some seconds.

I've not cancged the sample's code.
I'd like to know if I have to do some changes and if so, what do I have to do? Any explanation or link to explanations is wellcome!!

Thanks a lot

P.S. I'm using bass 1.8 with VB6

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: Problems with prjWriteWav and VBR mp3
« Reply #1 on: 24 Mar '03 - 13:48 »
If you try playing the VBR MP3 ripped from the AVI in an MP3 player, does it play fully then? If it does, please upload the VBR MP3, and I'll take a look...
     ftp://ftp.un4seen.com/incoming/

Movie Maniac

  • Guest
Re: Problems with prjWriteWav and VBR mp3
« Reply #2 on: 24 Mar '03 - 14:43 »

Quote

If you try playing the VBR MP3 ripped from the AVI in an MP3 player, does it play fully then?

Well, i've not done any test with a VBR mp3 ripped from an avi, just with an ogg file and it worked really well.
Then I tryed to convert some songs encoded with VBR mp3 and I encountered the problem.

Quote
If it does, please upload the VBR MP3, and I'll take a look...
     ftp://ftp.un4seen.com/incoming/


Ok, I'll upload a couple of songs that give the same problem.

Movie Maniac

  • Guest
Re: Problems with prjWriteWav and VBR mp3
« Reply #3 on: 24 Mar '03 - 14:45 »
P.S. when i sayd that I tryed with an Ogg file, I meant that the file was ripped off from an OGM file (avi doesn't support Ogg audio).

Bye

Movie Maniac

  • Guest
Re: Problems with prjWriteWav and VBR mp3
« Reply #4 on: 24 Mar '03 - 15:12 »
I've uploaded three songs (renamed with the prefix "upped by Movie Maniac"), but now I'm checking them and seems that the problem is due to a bad or damaged header. I can't understand why but it seems that both
winamp and prjwritewav recognize a lenght that's longer than the real one, so once you start the transcoding, it stops at the real end of the file but obviously the Position value is smaller than the one that corresponds to the file size.

Please check the mp3 that I uploaded and you'll understand in a moment, I'm not so sure upon the clearness of my explanation (I'm italian...)

I hope to have some good news ASAP
Thanks and bye

P.S two of those three songs (Propaganda and Nino Nardini) where tagged using "File Renamer 6 beta 3" wich could be downloaded from http://www.albert.nu/common.asp?sub=programs/default.asp?sub=renamer/main.htm. Is it possible that this software corruptes my mp3?

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: Problems with prjWriteWav and VBR mp3
« Reply #5 on: 24 Mar '03 - 16:31 »
The problem is that these files do not have a VBR header, so the length BASS_StreamGetLength returns is a guesstimate, until the entire file has been streamed. This does not affect decoding or playing the file - it'll still be decoded/played in full.

It's very unlikely a tagger would remove the VBR header - I think it's more likely that whatever created the AVI file did.

For what you're doing, I guess you probably don't need to know the exact length in advance, but if you do, you can use the BASS_MP3_SETPOS flag in the BASS_StreamCreateFile call. This makes BASS scan the MP3 file for the exact length, but that of course also increases the time taken for the stream to be created.

Movie Maniac

  • Guest
Re: Problems with prjWriteWav and VBR mp3
« Reply #6 on: 24 Mar '03 - 17:01 »
Well
thanks a lot!!!

I think that's the tagger to cause this problem since I notice that once I tag my files, mp3-Info extension (http://www.mutschler.de/mp3ext/) cannot recognize properly the mp3 (and unfortunately this happens not only with VBR files).

I should contact the author of the software and report this problem.

Thanks a lot for your support!

Bye

Sebastian_Mares

  • Guest
Re: Problems with prjWriteWav and VBR mp3
« Reply #7 on: 31 Mar '03 - 18:14 »
The problem is due to the ID3v2 tags. They are placed at the beginning of the MP3 file, which makes it almost imposible to detect the VBR header.

Visit http://users.belgacom.net/gc247244/index.html for more information (click the "No ID3" logo: ).

Movie Maniac

  • Guest
Re: Problems with prjWriteWav and VBR mp3
« Reply #8 on: 1 Apr '03 - 22:30 »

Quote

The problem is due to the ID3v2 tags. They are placed at the beginning of the MP3 file, which makes it almost imposible to detect the VBR header.

Visit http://users.belgacom.net/gc247244/index.html for more information (click the "No ID3" logo: ).


ah
I didn't knew this thing.

Thanks

Movie Maniac

  • Guest
Re: Problems with prjWriteWav and VBR mp3
« Reply #9 on: 1 Apr '03 - 23:07 »
However i forgot to say that, as Ian @ un4seen suggested, I used this simple line of code:

chan = BASS_StreamCreateFile(BASSFALSE, FileDialog.sFile, 0, 0, BASS_STREAM_DECODE Or BASS_MP3_SETPOS)

And it solved all my problems.
I was trying to use a progressbar to describe te overall status of the process, and I was setting
progressbar1.max=pos
but the BASS_STREAM_DECODE doesn't return always a correct value, and this cause the program to crash at the end of the conversion. Then i've added the BASS_MP3_SETPOS flag and now all works fine!

Thanks guys!

Bye

Azoth

  • Posts: 108
Re: Problems with prjWriteWav and VBR mp3
« Reply #10 on: 2 Apr '03 - 04:30 »
It was my understanding and maybe Ian can correct me, but I thought that the BASS_StreamGetLength() function skips over the ID3v2 header and roughly calculates the actual mp3 data length. Or does it simply use the filesize in the calculations? There is a very easy way to determine if a file has a v2 Header and the total size of the header. Retrieving the header size and adjusting appropriately may result in more accurate results.

.Azoth.

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: Problems with prjWriteWav and VBR mp3
« Reply #11 on: 2 Apr '03 - 10:43 »
Quote
The problem is due to the ID3v2 tags. They are placed at the beginning of the MP3 file, which makes it almost imposible to detect the VBR header.

Although dodgy ID3v2 tags can sometimes cause problems (ie. cause a file not to be detected as an MP3), that's not the case here - there's just no VBR header anywhere :)

Quote

I thought that the BASS_StreamGetLength() function skips over the ID3v2 header and roughly calculates the actual mp3 data length.

Yes, BASS does not include ID3v2 tags in the length calculations. The problem in this case is that they're VBR MP3s without VBR headers, so BASS has to estimate what the duration is (unless the BASS_MP3_SETPOS flag is used).

Irrational86

  • Posts: 960
Re: Problems with prjWriteWav and VBR mp3
« Reply #12 on: 2 Apr '03 - 16:35 »
is the BASS_MP3_SETPOS only for MP3s, or will it work with all streams (WAV/OGG/MP3/etc..)?

Ian @ un4seen

  • Administrator
  • Posts: 26083
Re: Problems with prjWriteWav and VBR mp3
« Reply #13 on: 2 Apr '03 - 20:10 »
The BASS_MP3_SETPOS flag only applies to MP3/2/1 files.

OGG files have their length stored in them, so that'll be exact (assuming the file's not corrupt). WAV files contain the average bitrate in the header, so no real need to scan them either :)