Trim Audio File

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Trim Audio File

Sudarshan Bisht
I need to trim down size/duration  of an audio file, for example I have a 5 MB audio file and I want to create an audio file having only 1 MB of size or 60 seconds of duration.
So to do this I need to first decode original audio file completely/partially and then encode the raw samples again until it reaches 1MB/60 sec.
Is there any other optimized way ?  For example playing with audio headers.
 
 

--
Regards,

Sudarshan Bisht

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Trim Audio File

Donny Viszneki
What muxer/codec do your audio files use?

On Thu, Oct 6, 2011 at 3:35 AM, Sudarshan Bisht
<[hidden email]> wrote:

> I need to trim down size/duration  of an audio file, for example I have a 5
> MB audio file and I want to create an audio file having only 1 MB of size or
> 60 seconds of duration.
> So to do this I need to first decode original audio file
> completely/partially and then encode the raw samples again until it reaches
> 1MB/60 sec.
> Is there any other optimized way ?  For example playing with audio headers.
>
>
> --
> Regards,
>
> Sudarshan Bisht
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>



--
http://codebad.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Trim Audio File

Sean McNamara-4
In reply to this post by Sudarshan Bisht
Hi,

On Thu, Oct 6, 2011 at 3:35 AM, Sudarshan Bisht
<[hidden email]> wrote:
> I need to trim down size/duration  of an audio file, for example I have a 5
> MB audio file and I want to create an audio file having only 1 MB of size or
> 60 seconds of duration.

There's a (AFAIK closed source) tool out there called mp3DirectCut
that does this *without* reencoding (so you don't suffer any quality
degradation at all): http://mpesch3.de1.cc/mp3dc.html

Not sure if there's an element out there for gstreamer that does
similar. And I have no idea if this is even theoretically possible
with other audio codecs. But at least for mp3, you should be able to
write a gstreamer element to do it without re-encoding, in the worst
case.

> So to do this I need to first decode original audio file
> completely/partially and then encode the raw samples again until it reaches
> 1MB/60 sec.

Try to avoid this, unless your encoded format is lossless (WAV, FLAC).
Re-encoding using lossy encoders is like making a photocopy of a
previously photocopied document: each time you do it, the quality
degrades slightly.


> Is there any other optimized way ?  For example playing with audio headers.

If you do modify the headers to reflect a different duration, you will
want to also get rid of the  extraneous data, to keep your file
compliant with the file format (just speaking in general here). It's
not a good idea to lie about the duration while keeping the actual
data intact; plus it wastes storage. If you're going to do this, then
do it by cutting the data out, too. Many frame-based codecs should
theoretically have a way for a program to automatically chop some
samples out of it without re-encoding.... the challenge is finding or
writing software to do what you're looking for with the file formats
you'll be using.

HTH,

Sean

>
>
> --
> Regards,
>
> Sudarshan Bisht
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
>
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Trim Audio File

Icarus Alive
In reply to this post by Sudarshan Bisht
On Thu, Oct 6, 2011 at 1:05 PM, Sudarshan Bisht
<[hidden email]> wrote:
> I need to trim down size/duration  of an audio file, for example I have a 5
> MB audio file and I want to create an audio file having only 1 MB of size or
> 60 seconds of duration.
> So to do this I need to first decode original audio file
> completely/partially and then encode the raw samples again until it reaches
> 1MB/60 sec.
> Is there any other optimized way ?  For example playing with audio headers.
>

Not sure if your end goal is something like "Audio thumbnails" e.g.
fixed size/duration audio samples, but if it is, you'd find some good
clues in here http://www.patentstorm.us/patents/7386357.html
But then, you see, it is patented :-). Never the less, you'd note that
fixed size, from the beginning of an audio file isn't a good idea, for
example if vocals do not even start in the first 60 mins of a song
(e.g. a song thumbnail/sampler).

the "mad" element has a src query API that seems to permit determining
the position, length -- which might come in handy to raise an event
when you reach a certain position in the file, s.t. you terminate
dumping it to file, and quit pipeline. This is coming from someone who
has spent a very little time, that too only recently with gstreamer,
and not very familiar with the API.

And then you have this http://mp3splt.sourceforge.net/mp3splt_page/home.php
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Trim Audio File

Sudarshan Bisht
Thanks all for your suggestions.


On Thu, Oct 6, 2011 at 9:18 PM, Icarus Alive <[hidden email]> wrote:
On Thu, Oct 6, 2011 at 1:05 PM, Sudarshan Bisht
<[hidden email]> wrote:
> I need to trim down size/duration  of an audio file, for example I have a 5
> MB audio file and I want to create an audio file having only 1 MB of size or
> 60 seconds of duration.
> So to do this I need to first decode original audio file
> completely/partially and then encode the raw samples again until it reaches
> 1MB/60 sec.
> Is there any other optimized way ?  For example playing with audio headers.
>

Not sure if your end goal is something like "Audio thumbnails" e.g.
fixed size/duration audio samples, but if it is, you'd find some good
clues in here http://www.patentstorm.us/patents/7386357.html
But then, you see, it is patented :-). Never the less, you'd note that
fixed size, from the beginning of an audio file isn't a good idea, for
example if vocals do not even start in the first 60 mins of a song
(e.g. a song thumbnail/sampler).

the "mad" element has a src query API that seems to permit determining
the position, length -- which might come in handy to raise an event
when you reach a certain position in the file, s.t. you terminate
dumping it to file, and quit pipeline. This is coming from someone who
has spent a very little time, that too only recently with gstreamer,
and not very familiar with the API.

And then you have this http://mp3splt.sourceforge.net/mp3splt_page/home.php
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



--
Regards,

Sudarshan Bisht

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel