Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th June 2022, 12:27   #1  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,542
High quality downsampling 96kHz to 48kHz

I have this strange anime BD whose jpn audio is 96kHz 24bit 7.1 THD.

What is the best way to dither it down to 48kHz wav?

I have googled a lot and I became even more confused.

Dithering or not? What kind of dithering?

ffmpeg native? sox?

Help.
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 8th June 2022, 14:57   #2  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
That conversion (96kHz 24bit -> 48kHz 24bit), only samplerate, don't need be dithered because are far of human ear limits (20 KHz [samplerate 40 KHz] 20 bits) and quantization errors can't be listenen.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 8th June 2022, 15:34   #3  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 2,309
Akira ?
This is the only one BD (of movie) i've encoutered with audio more than 48kHz, resulting in an around 15GB audio file size !
... Wait... it was the 5.1 audio on Akira which was with so insane stuff, not the 7.1.
Finaly maybe there is another insane audio anime...

Edit
My mistake, Akira is 5.1 24bit 192kHz !
__________________
My github.

Last edited by jpsdr; 8th June 2022 at 15:39.
jpsdr is offline   Reply With Quote
Old 8th June 2022, 21:21   #4  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,542
Quote:
Originally Posted by jpsdr View Post
Akira
Ghost in the shell – Solid state society
Code:
Audio #1
ID                             : 4352 (0x1100)
Menu ID                        : 1 (0x1)
Format                         : MLP FBA / AC-3
Format/Info                    : Meridian Lossless Packing
Format settings                : Dolby Surround EX
Muxing mode                    : Stream extension
Codec ID                       : 131
Duration                       : 1 h 48 min
Bit rate mode                  : Variable / Constant
Bit rate                       : 640 kb/s
Maximum bit rate               : 6 756 kb/s
Channel(s)                     : 8 channels / 6 channels
Channel layout                 : L R C LFE Ls Rs Lb Rb
Sampling rate                  : 96.0 kHz / 48.0 kHz
Frame rate                     : 31.250 FPS (1536 SPF)
Compression mode               : Lossless
Stream size                    : 498 MiB
Language                       : Japanese
Service kind                   : Complete Main
bsid                           : 6
Dialog Normalization           : -31
Dialog Normalization           : -31 dB
compr                          : -0.28
compr                          : -0.28 dB
acmod                          : 7
lfeon                          : 1
dialnorm_Average               : -31
dialnorm_Average               : -31 dB
dialnorm_Minimum               : -31
dialnorm_Minimum               : -31 dB
dialnorm_Maximum               : -31
dialnorm_Maximum               : -31 dB
dialnorm_Count                 : 1339
compr_Average                  : -4.24
compr_Average                  : -4.24 dB
compr_Minimum                  : -8.89
compr_Minimum                  : -8.89 dB
compr_Maximum                  : -0.56
compr_Maximum                  : -0.56 dB
compr_Count                    : 433
format_identifier              : AC-3
Source                         : 00005.m2ts
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 8th June 2022, 22:37   #5  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Question for Tebasuna: what would ResampleAudio() do in this scenario?

Assuming that I can't use SSRC 'cause 96000Hz ain't supported, suppose that I do the following:

Code:
video=LWLibavVideoSource("Ghost in the shell.m2ts")
audio=LWLibavAudioSource("Ghost in the shell.m2ts", stream_index=1)
AudioDub(video, audio)
ResampleAudio(48000)
how is it going to resample the 96000Hz source? What does ResampleAudio() do in this scenario to achieve the 96kHz -> 48kHz conversion?
The reason why I'm asking this is that I've been using this function for years and years, trusting the Avisynth implementation, to perform any kind of conversion (aside from 44 kHz <-> 48 kHz which I perform with SSRC() ) but in the wiki it doesn't say much http://avisynth.nl/index.php/ResampleAudio

Perhaps a better clarification of lines 1179 onward would help users https://github.com/AviSynth/AviSynth...core/audio.cpp
Then of course from line 1326 onwards it goes to assembly and I lose any clue about what is actually doing (although I'm sure you, Ferenc, Jean Philippe and others can).

Last edited by FranceBB; 8th June 2022 at 23:55.
FranceBB is offline   Reply With Quote
Old 8th June 2022, 23:58   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
JFYI,
IanB said some years back that ResampleAudio() had been re-written to be very nearly as good as SSRC(),
any articles saying SSRC() is much better, is well outdated.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 9th June 2022, 09:21   #7  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Quote:
Originally Posted by StainlessS View Post
ResampleAudio() had been re-written to be very nearly as good as SSRC(),
any articles saying SSRC() is much better, is well outdated.
Ah, sweet, thanks, I didn't know that.
That's great!
FranceBB is offline   Reply With Quote
Old 9th June 2022, 09:54   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Further to my prev post,

I just did a D9 search for "SSRC" by user IanB [posts not threads], and looked at the very first/earliest [date order] link from June 2005
(I dont really think this is the same link [EDIT: post] that I was referencing, but it is pertinent - I did not look at any other links)

https://forum.doom9.org/showthread.p...122#post672122
Quote:
Originally Posted by IanB View Post

As you are finding out the other part to this problem is audio sync.SSRC() give very high quality conversion between 2 audio sample rates but is limited to rates that have a limited rational relationship. ResampleAudio() does not have this restriction, but prior to Avisynth 2.5.6 the code had a slight creeping error in the calculations which caused distortion in the result. The 2.5.6 version now is quite close to SSRC() in quality. Timestretch() by the nature of the algorithm used causes noticable distortion in the result, generally use it for speech only, never for high quality music.

IanB
EDIT: I provided the link above for anybody that does not know that the little blue arrow following IanB name is also a link.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 9th June 2022 at 10:13.
StainlessS is offline   Reply With Quote
Old 9th June 2022, 18:05   #9  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by tormento View Post
Ghost in the shell – Solid state society
Code:
Format                         : MLP FBA / AC-3
Channel layout                 : L R C LFE Ls Rs Lb Rb
Sampling rate                  : 96.0 kHz
If you want recode that track to EAC3 with TotalCode Studio

ffmpeg -i "00005.m2ts" -map 0:1 -filter_complex "aresample=48000,pan=7.1|c0=c0|c1=c1|c2=c2|c3=c3|c4=c6|c5=c7|c6=c4|c7=c5" -rf64 auto -acodec pcm_s24le "7.1_Channels_R.wav"

Change the samplerate to the half is a easy process and don't need a sophisticated software, or dither, to convert after the output to a lossy encode.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 9th June 2022, 18:26   #10  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Of course you can use SSRC, instead aresample=48000, with

ssrc --rate 48000 "7.1_Channels_R96.wav" "7.1_Channels_R48.wav"

Or AviSynth:

LWLibavAudioSource("00005.m2ts", stream_index=1)
ConvertAudioToFloat()
SSRC(48000)
a=ConvertAudioTo24bit()
flrc = GetChannel(a, 1, 2, 3 ,4)
blr = GetChannel(a, 5, 6)
slr = GetChannel(a, 7, 8)
MergeChannels(flrc, slr, blr)
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 10th June 2022, 02:42   #11  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 539
The best resampler is still the sox resampler that can be used with ffmpeg when compiled with sox with the use of ffmpeg -i my-48000.wav -af aresample=resampler=soxr -ar 44100 my-44100.wav

https://trac.ffmpeg.org/wiki/FFmpeg%...oX%20Resampler
Balling is offline   Reply With Quote
Old 10th June 2022, 09:24   #12  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
I don't know what is the best.

There are a comparative here

And here free software to resample.

Sox can be used with ffmpeg (libsoxr included in BtbN-builds and in gyan.dev_full-builds) like Balling say or with the SoX package

SSRC can be used also with eac3to, than also can use r8brain.

Not included in comparative but see also a more updated ReSampler
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 10th June 2022 at 09:54.
tebasuna51 is offline   Reply With Quote
Old 10th June 2022, 12:37   #13  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Well I guess I'll stick with Avisynth anyway just for the ease of use.
After all, I'm already indexing the video and/or trimming it etc, so having everything in one place makes sense, especially now that StainlessS showed me that ResampleAudio() is just as good as SSRC() ever since Ian re-wrote it.
FranceBB is offline   Reply With Quote
Old 11th June 2022, 09:55   #14  |  Link
richardpl
Registered User
 
Join Date: Jan 2012
Posts: 272
Quote:
Originally Posted by Balling View Post
The best resampler is still the sox resampler that can be used with ffmpeg when compiled with sox with the use of ffmpeg -i my-48000.wav -af aresample=resampler=soxr -ar 44100 my-44100.wav

https://trac.ffmpeg.org/wiki/FFmpeg%...oX%20Resampler
Not correct at all, when using correct non-default parameters, aresample beats soxr.
richardpl is offline   Reply With Quote
Old 11th June 2022, 10:31   #15  |  Link
Brazil2
Registered User
 
Join Date: Jul 2008
Posts: 532
Quote:
Originally Posted by richardpl View Post
when using correct non-default parameters, aresample beats soxr.
How so ? In which domain exactly ?
Reminder: http://src.infinitewave.ca
Brazil2 is offline   Reply With Quote
Old 11th June 2022, 11:48   #16  |  Link
richardpl
Registered User
 
Join Date: Jan 2012
Posts: 272
That web page never provide input files to reproduce results.

Also as already said, aresample filter defaults are set for performance not for quality.
richardpl is offline   Reply With Quote
Old 11th June 2022, 13:05   #17  |  Link
Brazil2
Registered User
 
Join Date: Jul 2008
Posts: 532
Sorry but you don't answer the question.
Quote:
Originally Posted by richardpl View Post
when using correct non-default parameters, aresample beats soxr.
In which cases your claim is true ? Using which parameters ?
Please give examples and evidences.
Brazil2 is offline   Reply With Quote
Old 12th June 2022, 12:39   #18  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
I read the Resampler-Options, in ffmpeg docs, and the parameters not related with downmix, remap, async, soxr are:
Quote:
filter_size For swr only, set resampling filter size, default value is 32.
phase_shift For swr only, set resampling phase shift, default value is 10, and must be in the interval [0,30].
linear_interp Use linear interpolation when enabled (the default). Disable it if you want to preserve speed instead of quality when exact_rational fails.
exact_rational For swr only, when enabled, try to use exact phase_count based on input and output sample rate. However, if it is larger than 1 << phase_shift, the phase_count will be 1 << phase_shift as fallback. Default is enabled.
cutoff Set cutoff frequency (swr: 6dB point; soxr: 0dB point) ratio; must be a float value between 0 and 1. Default value is 0.97 with swr, and 0.91 with soxr (which, with a sample-rate of 44100, preserves the entire audio band to 20kHz).
filter_type For swr only, select resampling filter type. This only affects resampling operations. It accepts the following values:
'cubic' select cubic
'blackman_nuttall' select Blackman Nuttall windowed sinc
'kaiser' select Kaiser windowed sinc
kaiser_beta For swr only, set Kaiser window beta value. Must be a double float value in the interval [2,16], default value is 9.
What parameters we need change to improve the quality in the resample 96000 -> 48000?
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 12th June 2022, 19:20   #19  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 539
Quote:
Originally Posted by richardpl View Post
Not correct at all, when using correct non-default parameters, aresample beats soxr.
Well, yes, you and mkver and others wrote some stuff for it, maybe you should have updated wiki on trac with all those options, like you do for all the video [filters] options. Still, there were some issues with it recently in mpv, pull request is here https://github.com/mpv-player/mpv/pull/9990 that reverts https://github.com/mpv-player/mpv/co...96c4fead51578f because of

>but the patch is stuck in limbo

What patch, LOL?

Last edited by Balling; 12th June 2022 at 19:29.
Balling is offline   Reply With Quote
Old 13th June 2022, 16:50   #20  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
Personally...

I still use a very old program called Wavewizard
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:19.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.