|
View:
New views
16 Messages
—
Rating Filter:
Alert me
|
|
|
Music.LengthHello, I'm about to port an old Delphiapp to a nicer environment and
I'm looking at Gambas to do the work, Gambas is realy nice! One function I used in Delphi was to get the length of the sound played in TMediaPlayer, since I would like things done after 80%, 90%... Music.Pos tells me where I am, but I can not found a function that tells me how far I have to go. Is there a solution to this? -- Patrik Karlsson ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Music.LengthOn vendredi 20 juin 2008, Patrik Karlsson wrote:
> Hello, I'm about to port an old Delphiapp to a nicer environment and > I'm looking at Gambas to do the work, Gambas is realy nice! > > One function I used in Delphi was to get the length of the sound > played in TMediaPlayer, since I would like things done after 80%, > 90%... > Music.Pos tells me where I am, but I can not found a function that > tells me how far I have to go. > > Is there a solution to this? Alas, if I remember correctly, the SDL library has no method to know the length of the music! I don't know if it has changed recently, I will check... -- Benoit Minisini ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Music.LengthOn vendredi 20 juin 2008, Benoit Minisini wrote:
> On vendredi 20 juin 2008, Patrik Karlsson wrote: > > Hello, I'm about to port an old Delphiapp to a nicer environment and > > I'm looking at Gambas to do the work, Gambas is realy nice! > > > > One function I used in Delphi was to get the length of the sound > > played in TMediaPlayer, since I would like things done after 80%, > > 90%... > > Music.Pos tells me where I am, but I can not found a function that > > tells me how far I have to go. > > > > Is there a solution to this? > > Alas, if I remember correctly, the SDL library has no method to know the > length of the music! I don't know if it has changed recently, I will > check... Apparently, SDL cannot extract the audio length from some formats, like MP3 with a variable bitrate stream. I don't know why apparently the length of the audio is not encoded in the file header... -- Benoit Minisini ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Music.LengthIn the GambasDoc is an example on how to get information of a *.wav
file, including duration. See: http://gambasdoc.org/help/lang/read?show Maybe useful? On Fri, 2008-06-20 at 12:41 +0200, Benoit Minisini wrote: > On vendredi 20 juin 2008, Benoit Minisini wrote: > > On vendredi 20 juin 2008, Patrik Karlsson wrote: > > > Hello, I'm about to port an old Delphiapp to a nicer environment and > > > I'm looking at Gambas to do the work, Gambas is realy nice! > > > > > > One function I used in Delphi was to get the length of the sound > > > played in TMediaPlayer, since I would like things done after 80%, > > > 90%... > > > Music.Pos tells me where I am, but I can not found a function that > > > tells me how far I have to go. > > > > > > Is there a solution to this? > > > > Alas, if I remember correctly, the SDL library has no method to know the > > length of the music! I don't know if it has changed recently, I will > > check... > > Apparently, SDL cannot extract the audio length from some formats, like MP3 > with a variable bitrate stream. > > I don't know why apparently the length of the audio is not encoded in the file > header... > ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Music.Length2008/6/20 Benoit Minisini <gambas@...>:
> I don't know why apparently the length of the audio is not encoded in the file > header... Ok, I see, at http://www.mp3-tech.org/programmer/frame_header.html I found "There is no main file header in an MPEG audio file. An MPEG audio file is built up from a succession of smaller parts called frames. A frame is a datablock with its own header and audio information. In the case of Layer I or Layer II, frames are some totally independent items, so you can cut any part of MPEG file and play it correctly. The player will then play the music starting to the first plain valid frame founded. However, in the case of Layer III, frames are not always independant. Due to the possible use of the "byte reservoir", wich is a kind of buffer, frames are often dependent of each other. In the worst case, 9 frames may be needed before beeing able to decode one frame." -- Patrik Karlsson ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
|
|
|
Re: Music.LengthOn vendredi 20 juin 2008, Patrik Karlsson wrote:
> 2008/6/20 Benoit Minisini <gambas@...>: > > I don't know why apparently the length of the audio is not encoded in the > > file header... > > Ok, I see, at http://www.mp3-tech.org/programmer/frame_header.html I found > > "There is no main file header in an MPEG audio file. An MPEG audio > file is built up from a succession of smaller parts called frames. A > frame is a datablock with its own header and audio information. > In the case of Layer I or Layer II, frames are some totally > independent items, so you can cut any part of MPEG file and play it > correctly. The player will then play the music starting to the first > plain valid frame founded. However, in the case of Layer III, frames > are not always independant. Due to the possible use of the "byte > reservoir", wich is a kind of buffer, frames are often dependent of > each other. In the worst case, 9 frames may be needed before beeing > able to decode one frame." Hopefully, there is http://developer.kde.org/~wheeler/taglib.html Maybe a component could be made from this library to get meta information about audio files. -- Benoit Minisini ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Music.LengthIl venerdì 20 giugno 2008 13:09:34 Patrik Karlsson ha scritto:
> 2008/6/20 Benoit Minisini <gambas@...>: > > I don't know why apparently the length of the audio is not encoded in the > > file header... > > Ok, I see, at http://www.mp3-tech.org/programmer/frame_header.html I found > > "There is no main file header in an MPEG audio file. An MPEG audio > file is built up from a succession of smaller parts called frames. A > frame is a datablock with its own header and audio information. > In the case of Layer I or Layer II, frames are some totally > independent items, so you can cut any part of MPEG file and play it > correctly. The player will then play the music starting to the first > plain valid frame founded. However, in the case of Layer III, frames > are not always independant. Due to the possible use of the "byte > reservoir", wich is a kind of buffer, frames are often dependent of > each other. In the worst case, 9 frames may be needed before beeing > able to decode one frame." If you have "mp3info" installed in your system you can get the length: SHELL "mp3info -x " & "pathtofile.mp3" & " | grep 'Length:' | awk '{print $2}'" TO sString Stefano ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Music.LengthIl venerdì 20 giugno 2008 13:25:03 Stefano Palmeri ha scritto:
> > If you have "mp3info" installed in your system you can get the length: > > SHELL "mp3info -x " & "pathtofile.mp3" & " | grep 'Length:' | awk '{print > $2}'" TO sString > > Stefano > Little fix to avoid problems if a mp3 file name or tag contains the word "length". SHELL "mp3info -x " & "pathtofile.mp3" & " | grep '^Length:' | awk '{print $2}'" TO sString ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Music.LengthI've been working on this for mp3 files. It is really easy to just use
an external app to get the length of normal bitrate mp3 files as Stefano suggested. For variable bitrate mp3s, it's a little harder. There are visual basic scripts on the web that can do this... I have them somewhere in my files. If I can find them, I'll share them. However, it's not perfect. From what I remember, it goes through each frame of the mp3 and calculates an average length for each frame, to give you an approximate time length for the whole mp3. So seeking in that track will not work correctly, but it doesn't work perfectly in any player as far as I know. I never finished coding this into my own app though (which plays mp3 files from MySQL somewhat like Amarok does, but using VLC player). -Lee Benoit Minisini wrote: > On vendredi 20 juin 2008, Benoit Minisini wrote: > >> On vendredi 20 juin 2008, Patrik Karlsson wrote: >> >>> Hello, I'm about to port an old Delphiapp to a nicer environment and >>> I'm looking at Gambas to do the work, Gambas is realy nice! >>> >>> One function I used in Delphi was to get the length of the sound >>> played in TMediaPlayer, since I would like things done after 80%, >>> 90%... >>> Music.Pos tells me where I am, but I can not found a function that >>> tells me how far I have to go. >>> >>> Is there a solution to this? >>> >> Alas, if I remember correctly, the SDL library has no method to know the >> length of the music! I don't know if it has changed recently, I will >> check... >> > > Apparently, SDL cannot extract the audio length from some formats, like MP3 > with a variable bitrate stream. > > I don't know why apparently the length of the audio is not encoded in the file > header... > > ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Music.LengthOn Friday 20 June 2008, Benoit Minisini wrote:
> I don't know why apparently the length of the audio is not encoded in the file > header... > It is, but not in the way you think. In fact is the mp3 as we know nowadays a incomplete standard. We need to split the parts out of it. Mp3 is the encoding method only used as _data_. mpeg the layout of a block containing _data_ The file containing blocks of _data_ Audio is encoded, mp3 in this case, in blocks and each block has a header telling the rate used and block length. The block information is following a mpeg standard. Divide the bytes by rate and the time per block is known. Add the time per block for each block and you have the total play time. Storage on disk in a file was simple put all blocks after each other and without a file header descibing the content of the file. It was the inovation of mp3 encoding that triggers a group of enthousiast to write encoders/decoders to store there music that way and made it as a pseudo standard for the audiophiles, the 1/10 of the *.wav size that time in use. The early players read the rate from first block and used it for the whole file play and position, not looking every block. Just to win decoding time on the slow computers those days. They where not able to use variable rates at all. In the early 90's using 90% cpu time with win3.11 Later the mp3 encoding programs were changed to use variable rates and it was posible by using those block headers. To know the total time now you need to read the whole file and add the time per block. For file on local disk not a problem but what if it is on local network share or via internet? And how about live streams that use mp3 _encoding_? The total time is only known when the stream is ready. If the file had also container layout and could describe the content you can write the time into this container header and that does not exist for the populair mp3 encoded files. It is missing the file(container) that the mp3 encoding it is a good available encoding for streaming. Just jump somewhere in the stream and in short time it plays. side note 1) The real name of a file should be myaudio.mp3.mpeg just as myfileachive.tar.gz for files in a tar and late gzipped. I's just MS DOS (DiskOperatingSystem) did not allow more as 3 characters for the extension that made the *.mp3 naming scheme. side note 2) when you were able to write the total length in the header. Aborting a recording and you do not have a length to write and the mp3 duration is 0 or endless. In Result is you can't trust this value. Same problem why a *.avi file is not a good container for streaming with the seek index on the end of the file and the start of the file contains the amount of segments in the file to be able to find the start of the index. Aborting the write of a avi file with encoded (mp3, divx, cvid) data block makes the avi file corrupt for play. Remember the avi repair tools for this problem. The index is need while the encoded data blocks do not have(always) fixed lengths and decoding _must_ begin on a block start. Ron the 1'st ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
|