Recent

Author Topic: Trim audio file  (Read 774 times)

FelizKatus

  • Newbie
  • Posts: 5
Trim audio file
« on: May 19, 2025, 10:12:12 am »
Hi to all  :D

I need to create a simple program for cutting an audio file from one specific moment to another without losses.

It is desirable that the program could work not with one, but with several of the most common formats.

With what library can I do this?

I would be very grateful for:

- a link to the relevant documentation page
- a link to a code example
- a link to some tutorial describing a similar application
- a link to a source code of similar application

If anyone knows a similar application or tutorial for Embarcadero Delphi or CBuilder, that would also work for me.

Thanks :)

cdbc

  • Hero Member
  • *****
  • Posts: 2207
    • http://www.cdbc.dk
Re: Trim audio file
« Reply #1 on: May 19, 2025, 10:19:42 am »
Hi
Hmmm, for fpc/lazarus there's UOS, you can have a 'LookSee' for yourself...
Regards Benny

eta: Ohh, and welcome to the forum  :D
« Last Edit: May 19, 2025, 10:22:05 am by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Zvoni

  • Hero Member
  • *****
  • Posts: 2981
Re: Trim audio file
« Reply #2 on: May 19, 2025, 12:22:28 pm »
general overview:
https://wiki.freepascal.org/Audio_libraries

IIRC, Thaddy has used the BASS-lib extensively (?)

All said: Probably the most simple one would be to pass the chosen parameters to a TProcess calling ffmpeg CLI

something like
ffmpeg -ss StartSecond -i MyInputFile.mp3 -to EndSecond MyOutputfile.mp3
« Last Edit: May 19, 2025, 12:27:24 pm by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

cdbc

  • Hero Member
  • *****
  • Posts: 2207
    • http://www.cdbc.dk
Re: Trim audio file
« Reply #3 on: May 19, 2025, 12:45:41 pm »
Hi
If need be, @Metis has the bindings for libffmpeg...
Regards Benny

eta: I think the attached are the latest bindings...
« Last Edit: May 19, 2025, 12:53:24 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

FelizKatus

  • Newbie
  • Posts: 5
Re: Trim audio file
« Reply #4 on: May 19, 2025, 12:50:28 pm »
Hi Benny :-)

Thanks for your reply, I will study the documentation. But on this page:

https://wiki.freepascal.org/Multimedia_Programming

it is written that UOS is used for playing audio files, not for editing (if I am not mistaken, the wiki is down for three days, I can not check).

I see similar applications written using the FFmpeg library, for example:

https://github.com/mifi/lossless-cut?tab=readme-ov-file

I have little experience in programming. Maybe you know some tutorial or open source application to start working with this library?

--

Thanks for your reply, Zvoni :-)

I can not find an application called Teddy, can you give me a link?

I know how to trim a file from the command line, but I need an application with a graphic interface.

Thanks for the recommendation bass library, I will read the documentation. I would be very grateful if you give me a link to a specific documentation page or examples. As I said, I don't have much experience in programming :-)

Zvoni

  • Hero Member
  • *****
  • Posts: 2981
Re: Trim audio file
« Reply #5 on: May 19, 2025, 12:53:16 pm »

Thanks for your reply, Zvoni :-)

I can not find an application called Teddy, can you give me a link?

I know how to trim a file from the command line, but I need an application with a graphic interface.

Thanks for the recommendation bass library, I will read the documentation. I would be very grateful if you give me a link to a specific documentation page or examples. As I said, I don't have much experience in programming :-)
Thaddy is a User here.
Let's see if he'll find this thread
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

FelizKatus

  • Newbie
  • Posts: 5
Re: Trim audio file
« Reply #6 on: May 19, 2025, 01:25:36 pm »
Let's see. I'll read the documentation for now. Considering that I'm a graphic designer, it will be an unforgettable adventure :-)

I'll start with the BASS library, it seems simpler to me than FFmpeg.

Thanks, Zvoni :-)

metis

  • Sr. Member
  • ****
  • Posts: 302
Re: Trim audio file
« Reply #7 on: June 10, 2025, 12:58:41 pm »
@FelizKatus
BASS is simpler, but FFmpeg is much more versatile and powerful ;)

Quote
@Metis has the bindings for libffmpeg
Actually it's not me, who has the Bindings - You can download them here.
BTW: The next Release of FFPlay4Laz will work w/o them.

Quote
pass the chosen parameters to a TProcess calling ffmpeg CLI
For FFmpeg-Params, see this YT-Video and the associated ffmpeg-scripts, which are available in German, too.
For how to run the FFmpeg-CLI via TProcess, see RunFFmpeg, which is Part of FFGrab4Laz.
« Last Edit: June 10, 2025, 01:01:53 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

Fred vS

  • Hero Member
  • *****
  • Posts: 3622
    • StrumPract is the musicians best friend
Re: Trim audio file
« Reply #8 on: June 10, 2025, 02:54:56 pm »
it is written that UOS is used for playing audio files, not for editing (if I am not mistaken, the wiki is down for three days, I can not check).

Hello.

uos has no limit.  ;)

You may, of course, use it to copy part of a song and save it as wav or ogg.

Here a example done by Trustfm:
http://uos-forum.108.s1.nabble.com/Encoder-simple-demo-td1418.html
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018