Discussion:
[FFmpeg-user] Audio resampler (SoX) returns different result
林至善
2018-11-19 08:14:03 UTC
Permalink
Hi all,

I need a down-sampled(=8kHz) version of my input.wav file (=16kHz).

According to
https://trac.ffmpeg.org/wiki/FFmpeg%20and%20the%20SoX%20Resampler,
I use the command below

ffmpeg -i In16k.wav -af aresample=resampler=soxr -ar 8000 Out8k.wav

It works well, but I found that every time I run the command above,
it returns the "Out8k.wav" with a slightly different(in PCM value).

The question is :
*Is the difference I found a normal phenomenon?
*If I want a resampler which always returns the same result, how can I do?

Sorry about my poor English.
Thank you all.


LCS
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg
Moritz Barsnick
2018-11-19 14:02:02 UTC
Permalink
Hi,
Post by 林至善
I need a down-sampled(=8kHz) version of my input.wav file (=16kHz).
According to
https://trac.ffmpeg.org/wiki/FFmpeg%20and%20the%20SoX%20Resampler,
I use the command below
ffmpeg -i In16k.wav -af aresample=resampler=soxr -ar 8000 Out8k.wav
It works well, but I found that every time I run the command above,
it returns the "Out8k.wav" with a slightly different(in PCM value).
Interesting. But first of all, I believe your command line is wrong.
"-ar" uses ffmpeg's native resampler, I believe. Using the filter, you
need to pass the rate to the filter itself:

ffmpeg -i In16k.wav -af aresample=resampler=soxr:sample_rate=8000 Out8k.wav

You could also just use any other resampler, e.g. by omitting "-af
aresample=resampler=soxr" fully.

I don't have soxr support, so I can't reproduce your issue. It should
be deterministic. Perhaps some metadata thing.
Post by 林至善
*If I want a resampler which always returns the same result, how can I do?
Can you try whether the command line option "-bitexact" changes
anything?

Moritz
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-reques
Carl Eugen Hoyos
2018-11-19 14:27:55 UTC
Permalink
This post might be inappropriate. Click to display it.
林至善
2018-11-20 02:03:48 UTC
Permalink
Hello *Moritz*:

*Thank you so much for responding to my issue :)*
Post by Moritz Barsnick
Interesting. But first of all, I believe your command line is wrong.
"-ar" uses ffmpeg's native resampler, I believe. Using the filter, you
ffmpeg -i In16k.wav -af aresample=resampler=soxr:sample_rate=8000
Out8k.wav

I have tried it, but got the same result(resampler works well but slightly
different when I run this command again).
Post by Moritz Barsnick
You could also just use any other resampler, e.g. by omitting "-af
aresample=resampler=soxr" fully.
Thanks! It is the default resampler I guess. It is deterministic.
But the default resampler brings some "aliasing" to the resampled auidio.
Post by Moritz Barsnick
I don't have soxr support, so I can't reproduce your issue. It should
be deterministic. Perhaps some metadata thing.
Metadata. I am not sure what it means but I think it must be something
important.
Is it about my environment setting? Can I fix it?

//
----------------------------------------------------------------------------------------------------------------------------------

Hello *Carl Eugen*:

*So pleased to hear from you :)*
Post by Moritz Barsnick
Please always provide the command line you test together with
the complete, uncut console output when asking for support here.
↓ run "ffmpeg -i Fsweep16.wav -af aresample=resampler=soxr -ar 8000
Fsweep8.wav"
[image: 159.JPG]
↓ run again.
[image: 147.JPG]
Post by Moritz Barsnick
FFmpeg's default resampler is deterministic.
Thank you for your advice. I tried this:

ffmpeg -i Fsweep16.wav -ar 8000 Fsweep8.wav

It works well and it is deterministic. It uses the resampler "swr" I guess,
but with slightly aliasing in resampled audio.
I think the 'soxr' is necessary in my case, but I am not sure if I should
ask for support here or libsxor?

//
----------------------------------------------------------------------------------------------------------------------------------

Thank you all again for your support.

LCS
Moritz Barsnick
2018-11-20 11:33:03 UTC
Permalink
Post by 林至善
It works well and it is deterministic. It uses the resampler "swr" I guess,
but with slightly aliasing in resampled audio.
I think the 'soxr' is necessary in my case, but I am not sure if I should
ask for support here or libsxor?
I could now reproduce your issue with a libsoxr enabled ffmpeg. It
appears that libsoxr produces slightly different results each time, as
if rounding arbitrarily. It seems indetermenistic. You should take it
up with libsoxr.

The try native resampler, but with some of the other dither methods
described in
$ ffmpeg -h filter=aresample
and in the "Resampler Options" section of ffmpeg's documentation.

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user

Loading...