20 Jun '13 - 00:56 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: I need help with cuting files.  (Read 663 times)
Wishmaster
Posts: 124


« on: 2 Mar '11 - 06:11 »
Reply with quoteQuote


Hi

Is it possible to set the Start / End position of a File (.mp3) within  BASS_StreamCreateFile() and get the remaining length in byte (minus the Start/End Position)?

Something like this
Chan_Source:= BASS_StreamCreateFile(false, PChar(FSource), Start, End, BASS_STREAM_DECODE);

TotalSamples:= TRunc(BASS_ChannelGetLength(Chan_Source, BASS_POS_BYTE) / 2);
FLAC_Encoder.Encoder_Create(PChar(FDestination), TotalSamples)

I use the DLL encoder like (libFLAC.dll, lame_enc.dll, TTALib.dll, ...) and for some encoders like, libFLAC  I have to set the length in bytes when initializing the encoder. It works great if I convert the whole file, but not if i try to cut file.


thx
Logged
Ian @ un4seen
Administrator
Posts: 15366


« Reply #1 on: 2 Mar '11 - 16:53 »
Reply with quoteQuote

Please note the BASS_StreamCreateFile "offset" and "length" parameters are dealing in file positions, which can't be set arbitrarily with most file formats, eg. the file header might be missed. Instead of using them, you should usually use BASS_ChannelSetPosition to seek to the start position and then limit your processing to the end position. Here is a previous thread on the subject, including some example code...

   www.un4seen.com/forum/?topic=9167
Logged
Wishmaster
Posts: 124


« Reply #2 on: 4 Mar '11 - 07:11 »
Reply with quoteQuote

Hi

thanks, it looks like it works! I will test it a little longer.
can you also help me with encoding Progress?

                 (* Set Cut Position *)
                  Start_Bytes:= BASS_ChannelSeconds2Bytes(Chan_Source, Start_Pos_MS / 1000); (* get start position in bytes *)
                  Stop_Bytes:=  BASS_ChannelSeconds2Bytes(Chan_Source, Stop_Pos_MS / 1000);  (* get end position in bytes *)
                  Todo_bytes:=  Stop_Bytes - Start_Bytes;
                  BASS_ChannelSetPosition(Chan_Source, Start_Bytes, BASS_POS_BYTE);


                 if (Start_Bytes > 0) or (Stop_Bytes > 0) then
                  begin
                   while (Todo_bytes <> 0) do
                    begin
                      BytesRead:= BASS_ChannelGetData(Chan_Mixer, @Buff32, Min(Todo_bytes, SizeOf(Buff32)));
                     if (BytesRead = -1) or (FAbord) then
                       Break;

                      Dec(todo_bytes, BytesRead);

                    //  PercentDone:= ((100 * BASS_ChannelGetPosition(Chan_Source, BASS_POS_BYTE)) div BASS_ChannelGetLength(Chan_Source, BASS_POS_BYTE));
                  //    SendMessage(FWndHandle, WM_RIPPER_UPDATE, WM_RIPPER_PROGRESS, PercentDone);    (* [0..100]% *)

                    end;
                  end

thx
Logged
Ian @ un4seen
Administrator
Posts: 15366


« Reply #3 on: 4 Mar '11 - 15:00 »
Reply with quoteQuote

The progress there would be calculated like this: PercentDone = 100 * (Stop_Bytes - Start_Bytes - Todo_bytes) / (Stop_Bytes - Start_Bytes)
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines