How to convert WAV to MP3 with acs lazarus / 21-General ---------------------------------------------------------------------- myisjwj · 2023-09-08 14:38 How to convert WAV to MP3 with acs ---------------------------------------------------------------------- toby · 2023-09-08 16:00 is acs the online converter? you can use ffmpeg directly with tprocess.execute( or sysutils.executeprocess( ---------------------------------------------------------------------- cdbc · 2023-09-08 16:52 Hi Google for LAME library, "lame mp3 encoder download" preferably with pascal/fpc/delphi bindings... If your mention of acs concerns this: https://wiki.freepascal.org/ACS, then I think the bindings are already there, you just have to figure out how to call them exactly, maybe this: https://lame.sourceforge.io/ has the info you need  Regards Benny ---------------------------------------------------------------------- TRon · 2023-09-08 17:16 Quote from: myisjwj on September 08, 2023, 04:38:17 pmHow to convert WAV to MP3 with acs There seem to be a fileconvert example that convert files based on extension. Have you tried it ? (I am not sure it supports mp3 out of the box or that you need to include the correct units and/or install the correct dependencies (if any) first). ---------------------------------------------------------------------- myisjwj · 2023-09-10 03:35 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button4Click(Sender: TObject);var  FileIn: TACSFileIn;  FileOut: TACSFileOut;begin  FileIn:=TAcsFileIn.Create(Nil);  FileIn.FileName:='C:\11.wav' ;  FileIn.StartSample:=0;  FileIn.EndSample:=-1;  FileIn.Loop:=False;  FileIn.Open();  FileOut:=TAcsFileOut.Create(Nil);  FileOut.FileName:='C:\11.mp3';  FileOut.Input:=FileIn;  FileOut.PrefetchMode:=pmAuto;  FileOut.FileMode:=foRewrite;  FileOut.Run();  //FileOut.Free;  //FileIn.Free;end; procedure TForm1.Button5Click(Sender: TObject);var  i:Integer;begin  ComboBox1.Clear;   for i := 0 to FileFormats.Count-1 do    if TACSFileFormat(Fileformats[i]).FileClass.InheritsFrom(TACSCus tomFileOut) then      ComboBox1.Items.Add(TACSFileFormat(Fileformats[i]).Extension);//The supported extensions are mp3 and wavend; If you add the following code FileOut.Free; FileIn.Free; It can't be documented. If you add the following code //FileOut.Free; //FileIn.Free; Generate an aa.mp3 file, size 648. But it can't be played. ---------------------------------------------------------------------- TRon · 2023-09-10 23:52 @myisjwj Your code looks fine to me (but I am not really familiar with ACS components). Your result is even better than mine because my MP3 output stays at zero bytes (instead converting wav to og results in an ogg output file of 56 bytes for me). I have no idea what might be the issue there. Trying to loop through the (output) status or (input) progress does not yield any better results for me. Oh, and ofc you should free both instances when you are done (even if that results in a wrong result). If you can't get a better answer from the author here on the forums (he is active though not very much recently) then consider asking for help on the github page here. BTW on what platform are you trying this because I tried on Linux and had to manually edit the ACS sources to change the library path (of libmp3lame) to something sane. ---------------------------------------------------------------------- myisjwj · 2023-09-11 01:37 system:windows7 ---------------------------------------------------------------------- jamie · 2023-09-11 02:52 I don't think that is going to create a mp3. I really think there is more to it. ---------------------------------------------------------------------- cdbc · 2023-09-11 20:26 Hi I've spent the last couple of hours, trying to get acs to compile on linux, I find it's generally flawed! I'll play with it some more... No wonder, you couldn't get a result, right off the bat  Regards Benny ---------------------------------------------------------------------- TRon · 2023-09-12 02:09 @cdbc: I got the components from OPM (manually downloaded) then copied out the src folder of the package zip file to a subdirectory of my testproject then compiled a FPC console application with fpc -Fu"./acs/*" -Fu"./acs/formats/*" -Mdelphi -B testproject.pas As said, I needed to change the library names in some of the unit source-files as they included the full path (using a wrong path for my debian machine) and ofc acs has some dependencies that need to be met based on what it is you are trying to accomplish with your code. I haven't had a in depth look as of how the components are suppose to work. Seeing the documentation mentioning that it started out as normal classes have led me to assume that they should work without the need for a GUI and/or use of GUI components. @jamie: The example is telling us that that is the way it is suppose to work, provided that you include the right units that register additional classes/extension so that the different fileformats are (actually) supported. A bit like how TFPImage works with supporting different fileformats or compiling in support for SSL in web classes automatically when you include the correct unit(s). ---------------------------------------------------------------------- myisjwj · 2023-09-12 05:16 It's ready to use. First copy unit Lame_Enc under https://blog.csdn.net/y281252548/article/details/127314378 Lazarus is going to change that. Program segment as follows Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  Tin,Tout:TMemoryStream;  rc:Integer;begin  FMp3BlockAlign:=1;  vConfig.Format.dwConfig:=0;  vConfig.Format.MP3.byMode:=3;//BE_MP3_MODE_MONO = 3  vConfig.Format.MP3.dwSampleRate:=11025;//This value is the same as the SampleRate of the wav file  vConfig.Format.MP3.wBitrate:=16;//n-16   rc:=beInit;  Tin:=TMemoryStream.Create;  Tin.LoadFromFile('c:\1116.wav');  Tout:=TMemoryStream.Create;  rc:=beEnc(Tin,Tout);  Tout.SaveToFile('c:\temp.mp3');  ShowMessage(IntToStr(rc));end;