resampling and reformatting audio when rate/format will not need to change

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

resampling and reformatting audio when rate/format will not need to change

Charlie Laub

I am processing audio streams and need to implement reformatting (e.g. changing of the bit depth) and resampling. I am doing this via gst-launch. Have a couple of questions about the behavior of these elements and how they should be used together in the pipeline.

 

In some cases I might not know the input audio caps, and they might already be the same as the desired output caps. In that case, does the resampling code actually run as if it was changing the sample rate, or is the element automatically bypassed when it discovers that no change is needed? I looked at the code in gstaudioresample.c but I did not see anything about it.

 

Also, if I need to reformat AND resample, can I construct the pipeline like this:

… ! audioconvert ! audioresample ! audio/x-raw,format=NEW_FORMAT,rate=NEW_RATE ! …

 

Or do I need to explicitly provide caps for both elements (audioconvert and audioresample), like this:

… ! audioconvert ! audio/x-raw,format=NEW_FORMAT  ! audioresample ! audio/x-raw,rate=NEW_RATE ! …

 

 


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

Re: resampling and reformatting audio when rate/format will not need to change

Tim Müller
On Fri, 2018-03-16 at 09:10 -0700, Charlie Laub wrote:

Hi Charlie,
 
> In some cases I might not know the input audio caps, and they might
> already be the same as the desired output caps. In that case, does
> the resampling code actually run as if it was changing the sample
> rate, or is the element automatically bypassed when it discovers that
> no change is needed? I looked at the code in gstaudioresample.c but I
> did not see anything about it.

Yes, both elements should work in passthrough mode if downstream can
accept the input caps and no work is needed.

> Also, if I need to reformat AND resample, can I construct the
> pipeline like this:
> … ! audioconvert ! audioresample ! audio/x-
> raw,format=NEW_FORMAT,rate=NEW_RATE ! …

Yes, that should work.
 
> Or do I need to explicitly provide caps for both elements
> (audioconvert and audioresample), like this:
> … ! audioconvert ! audio/x-raw,format=NEW_FORMAT  ! audioresample !
> audio/x-raw,rate=NEW_RATE ! …

This should also work, but not be needed.

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

RE: resampling and reformatting audio when rate/format will not need to change

Charlie Laub
Tim, thanks for the fast reply.

One more question regarding audioresample: is there an anti-aliasing filter already built in when downsampling, or does the user need to do that explicitly upstream of the resampling element? I would always using the Kaiser (default) method.


-----Original Message-----
From: gstreamer-devel <[hidden email]> On Behalf Of Tim Müller
Sent: Friday, March 16, 2018 9:45 AM
To: Discussion of the development of and with GStreamer <[hidden email]>
Subject: Re: resampling and reformatting audio when rate/format will not need to change

On Fri, 2018-03-16 at 09:10 -0700, Charlie Laub wrote:

Hi Charlie,
 
> In some cases I might not know the input audio caps, and they might
> already be the same as the desired output caps. In that case, does the
> resampling code actually run as if it was changing the sample rate, or
> is the element automatically bypassed when it discovers that no change
> is needed? I looked at the code in gstaudioresample.c but I did not
> see anything about it.

Yes, both elements should work in passthrough mode if downstream can accept the input caps and no work is needed.

> Also, if I need to reformat AND resample, can I construct the pipeline
> like this:
> … ! audioconvert ! audioresample ! audio/x-
> raw,format=NEW_FORMAT,rate=NEW_RATE ! …

Yes, that should work.
 
> Or do I need to explicitly provide caps for both elements
> (audioconvert and audioresample), like this:
> … ! audioconvert ! audio/x-raw,format=NEW_FORMAT  ! audioresample !
> audio/x-raw,rate=NEW_RATE ! …

This should also work, but not be needed.

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com _______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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