Log in

View Full Version : LSmash weird Audio [JFYI]


StainlessS
20th February 2024, 13:30
DUFF THREAD, WILL BE DELETED, Please Ignore.

There is something real weird with new LWLibavAudioSource(ff_options="drc=0,...") stuff on WAV audio,
so far as I know, the eg "NICAC3Source(...,DRC=0)" is supposed to remove EXISTING DRC from AC3 files,
but if used on WAV, LWLibavAudioSource(ff_options = "drc=0,...") then seems to affect WAV, even when no drc is applied, think should only apply any drc stuff to AC3 [or other DRC applied audio],
and not apply to WAV ie linear non-compressed [without drc applied].
MeGUI Produces real nasty audio when "Normalize Peaks to:- 98" used in AAC audio settings with new LWLibavAudioSource(ff_options = "drc=0,...") stuff on linear WAV source file.

I'm going back to older LSmash before recent DRC thingy (before ff_options ="drc=0,..."), until I at least figure out what the new plug is doing wrong/different, I got many encodes with nasty audio.

I've long converted all source audio to 16 bit stereo WAV using FFMPEG script, with DRC removed, prior to encode script.
(to reduce excessive [eg 20->30 min] MEGUI normalize times with eg 24/96 bit, 7.1 audio source, if converted to 16 bit stereo within script)
EDIT: Same nasty result whether DRC box ticked or not in MEGUI audio encode AAC settings.

EDIT: It is totally possible, [even probable] that I totally misunderstand the drc thingy, but, what I always used to do with good output audio, has now totally horrible result
when ff_options="drc=0,..." rather than drc=0 as in earlier version LSMash audio source filter with WAV source.

StvG
20th February 2024, 21:53
I cannot reproduce the issue.
I used the following script to test:
LWLibavAudioSource("input.wav")
#LWLibavAudioSource("input.wav", ff_options="drc_scale=0")

1. ffmpeg -i above_script_with_undefined_drc.avs -c:a pcm_s32le drc.wav
2. ffmpeg -i above_script with_drc0.avs -c:a pcm_s32le drc1.wav

Both drc.wav and drc1.wav are identical (same SHA256 hash).

StainlessS
21st February 2024, 01:09
1) I convert source AC3 or other input format audio to 16 bit stereo intermediate.WAV using FFMPEG script.
2) Use eg avs script, LWLibavAudioSource("intermediate.wav", ff_options="drc_scale=0")
3) Use MegUI to use source step 2) avs script, Nero AAC encode to AAC with Normalize Peaks to 98.

1. ffmpeg -i above_script_with_undefined_drc.avs -c:a pcm_s32le drc.wav
2. ffmpeg -i above_script with_drc0.avs -c:a pcm_s32le drc1.wav
Maybe try use old pre change DLL LWLibavAudioSource(drc_scale=0), compare with new DLL LWLibavAudioSource(ff_options="drc_scale=0")

EDIT: The Convert to 16 bit stereo script

REM Convert audio to 16 bit stereo
REM We DO NOT LIKE SPACES IN FILE NAMES (REM == REMark ie comment)
REM We DO NOT LIKE ACCENTS IN FILE NAMES.


setlocal

REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"

REM Where to get input file, No terminating Backslash, "." = current directory
set INDIR="."


REM Where to place output file, No terminating Backslash.
set OUTDIR=".\OUTPUT"


FOR %%A IN (*.thd *.dts *.ac3 *.w64 *.aac *.m4a *.eac3 *.wav *.mp3) DO (
%FFMPEG% -i "%INDIR%\%%A" -vn -acodec pcm_s16le -ac 2 "%OUTDIR%\%%~nxA.WAV"

)


EDIT:
Good pre change dll, LSMASHSource_x64_1147.0.0.0.06Nov2023_[Asd-g].dll # Good, pre drc stuff, LWLibavAudioSource(drc_scale=0)
One of the bad dll's, LSMASHSource_x64_1167.0.0.0.12Jan2024.dll # not good new dll, LWLibavAudioSource(ff_options="drc_scale=0")

EDIT: I'll try create a reproducible file set.

StvG
21st February 2024, 02:15
I don't use MeGUI. I installed the latest version (https://sourceforge.net/projects/megui/files/megui-stable/2944/) but I didn't find NeroAAC for audio encoding (only FFmpeg AAC..).

I did one more test:
1. Converted ac3 5.1 to 16-bit wav 2.0 (ffmpeg -i in.ac3 -c:a pcm_s16le -ac 2 out.wav)
2. Used LWLibavAudioSource("out.wav", ff_options="drc_scale=0") with LSMASHSource_x64_1167.0.0.0 (ffmpeg -i script.avs -c:a -pcm_s32le 1.wav)
3. Used LWLibavAudioSource("out.wav") with LSMASHSource_x64_1167.0.0.0 (ffmpeg -i script.avs -c:a -pcm_s32le 2.wav)
4. Used LWLibavAudioSource("out.wav", drc_scale=0) with LSMASHSource_x64_1147.0.0.0 (ffmpeg -i script.avs -c:a -pcm_s32le 3.wav)

All three files (1.wav, 2.wav, 3.wav) have same SHA256 hash.

Edit: I downloaded Nero AAC Encoder (https://www.videohelp.com/software/Nero-AAC-Codec).
I tested:
1. ffmpeg -i script.avs -f wav - | neroAacEnc.exe -ignorelength -q 0.5 -if - -of 1.mp4 (script.avs: LWLibavAudioSource("out.wav", ff_options="drc_scale=0") with LSMASHSource_x64_1167.0.0.0)
2. ffmpeg -i script.avs -f wav - | neroAacEnc.exe -ignorelength -q 0.5 -if - -of 2.mp4 (script.avs: LWLibavAudioSource("out.wav", "drc_scale=0) with LSMASHSource_x64_1147.0.0.0)
3. Nero AAC Encoder doesn't output identical files even if I run the same command twice. So to compare 1.mp4 and 2.mp4 I created the following script:
BlankClip(length=65000, pixel_type="yv12")
AudioDub(LWLibavAudioSource("1.mp4"))
a=Waveform()
AudioDub(LWLibavAudioSource("2.mp4"))
Waveform()
WriteFileIf("output.txt", "LumaDifference(a) > 0", "current_frame")

After the run of the script, the "output.txt" was empty (meaning both 1.mp4 and 2.mp4 are identical).

StainlessS
22nd February 2024, 09:11
Sorry StvG,
this thread is totally bogus, is self inflicted problem, not problem of LSMash.

I made some changes somewhere in big (35KB,700 line) script, still not sure where the problem resides and as I updated on all machines, I dont
positively know what I did wrong. I have however managed to kludge the problem until I find it.

Anyway, part of fix was to convert all input WAVs to float, I'm using this if anybody finds it of use.

ConvStereoAudio.Bat

REM Convert audio to WAV, 32 bit FLOAT stereo, 44.1KHz without dynamic range compression.
REM We DO NOT LIKE SPACES IN FILE NAMES (REM == REMark ie comment)
REM We DO NOT LIKE ACCENTS IN FILE NAMES.
REM Input from same directory at this bat file, output to existing "OUTPUT" directory in same directory as this bat file.

setlocal

REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"

REM Where to get input file, No terminating Backslash, "." = current directory
set INDIR="."

REM Where to place output file, No terminating Backslash.
set OUTDIR=".\OUTPUT"


FOR %%A IN (*.thd *.dts *.ac3 *.w64 *.aac *.m4a *.eac3 *.wav *.mp3) DO (
%FFMPEG% -drc_scale 0 -i "%INDIR%\%%A" -vn -acodec pcm_f32le -ac 2 -ar 44100 "%OUTDIR%\%%~nxA.WAV"
)


I'll probably delete this dodgy thread in a couple of days.

Again, sorry for this waste of space :(

Emulgator
24th February 2024, 19:39
If somebody else is happen to run into the same condition it maybe helpful to leave the thread up...

StainlessS
24th February 2024, 23:22
OK boss, up it stays.