problems on custom AviSynth-Node

Questions and answers on how to get the most out of FFAStrans
Post Reply
ThomasM
Site Admin
Posts: 231
Joined: Wed Feb 22, 2017 6:36 am

problems on custom AviSynth-Node

Post by ThomasM »

Hi all,

I have this script:

Code: Select all

m_clip=AssumeFPS(m_clip, 25, 1, true)
m_clip=ConvertAudioTo16bit(m_clip) 
Return m_clip
AssumeFPS works, but ConvertTo16Bit does not. The file which comes out has 32Bit (VLC-player Codec-information). The original provided *.AVI has also only 16Bit.
TonfilmTest.xml
(19.64 KiB) Downloaded 451 times
any ideas?

greetings,
tom
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: problems on custom AviSynth-Node

Post by emcodem »

Hi Thomas,
i see you have a h264 encode after the avisynth conversion. The audio codec at this encode node is the one that finally decides which bit resolution he likes to have and transform any input bit format to his preferred one.
Allow me a question: why is it of interest for you that the internal bit resolution of the aac codec is 32bit float?

cheers, emcodem
emcodem, wrapping since 2009 you got the rhyme?
ThomasM
Site Admin
Posts: 231
Joined: Wed Feb 22, 2017 6:36 am

Re: problems on custom AviSynth-Node

Post by ThomasM »

Hi emcodem,

thank you for responding that fast...

OK, I did not knew that. I thought "16 Bit in - 16 Bit out" would be the behaviour.

Anyway, IMHO 32Bit float or even 24 Bit fix is just a senseless resolution for a consumerformat like AAC... :P

cheers,
tom
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: problems on custom AviSynth-Node

Post by emcodem »

hey Thomas :)
well aac is lossy compression so it is not like aac has a bit resolution in its compressed form.
Before encoding and after decoding it is 32f but that does not really influence the final result after encoding. The result is mainly influenced by the content..
Why were you working on the topic? ..trying to save bitrate?
emcodem, wrapping since 2009 you got the rhyme?
ThomasM
Site Admin
Posts: 231
Joined: Wed Feb 22, 2017 6:36 am

Re: problems on custom AviSynth-Node

Post by ThomasM »

Hey emcodem,

I´m just wondering why the encoder is boosting the bitrate to 32Bit float, even when the input is 16 Bit. I think if someone wants to squeeze a mediafile to something like h264 and aac, an upsampling to 32Bit Float is somewhat counterproductive. In my case it is not about saving bitrate but the principle - you know...

I tried a Custom FFmpeg-node:

-c:v libx264 -b:v 2M -x264-params nal-hrd=cbr -profile:v baseline -level 3.0 -pix_fmt yuv420p
-minrate 2M -maxrate 4M -bufsize 4M
-c:a aac -b:a 192k -ar 48k -sample_fmt s16

but the outcome failed: No viedo or audio found in media.

with

-c:v libx264 -b:v 2M -x264-params nal-hrd=cbr -profile:v baseline -level 3.0 -pix_fmt yuv420p
-minrate 2M -maxrate 4M -bufsize 4M
-c:a aac -b:a 192k -ar 48k

it works fine, but with 32bit float on the output.

btw: what do you mean with
Before encoding and after decoding it is 32f
? I am afraid I do not get the point...

cheers,
thomas
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: problems on custom AviSynth-Node

Post by emcodem »

Ah, i see so it is more theoretical :-)
OK, so you seem to mix up uncompressed PCM Audio with the lossy compressed Codec. Let me try to explain.

Again, AAC is a compressed codec. So the encoded bitstream as it resides on harddrive or as it is transferred via stream does not have a fixed size of Bits per sample. Only uncompressed Audio formats have a fixed number of bits per sample.
AAC will compress whatever you input as good as it can to the target bitrate, so it does not matter at all if the uncompressed input was 16 bit or 32 bit. In the end, the outgoing bitrate needs AAC to cut off this and that parts of the wave curves anyway.

But, for explaination: of course, BEFORE the audio is encoded it WAS uncompressed and also it is uncompressed again directly after decoding (right before it goes from RAM to the Sound Card in a player like VLC). BUT it does not matter for the AAC Codec which format it was before, and as it cannot be restored Lossless, it also does not matter which format it is after Decoding.

In the end, most lossy audio compressors only support a single input bit resolution because and just does not matter which one they choose, they just go for the best one.
Why choosing 32bit float for input and output from and to a lossly audio encoder: because literally any other format (<=32bit) can be converted into 32bit float 100% lossless.
emcodem, wrapping since 2009 you got the rhyme?
ThomasM
Site Admin
Posts: 231
Joined: Wed Feb 22, 2017 6:36 am

Re: problems on custom AviSynth-Node

Post by ThomasM »

literally any other format (<=32bit) can be converted into 32bit float 100% lossless
-> that´s true.

I was not aware of this behaviour. Is it the same with all other lossy codecs? :)
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: problems on custom AviSynth-Node

Post by emcodem »

To be honest i never had a look but i tend to say yes but i don't know and it might not be the same for 2 different en/decoders for the same format; it is a choice of the developer in charge :-)
In the end this also depends on the environment. E.g. if you have a hardware MP3 Player (let us say a non-smart Car Radio), which does not have any OS but just hardware instead, the hardware might not have a 32bit processor. in this case they will most likely output 16bit from the decoded mp3 :-)
emcodem, wrapping since 2009 you got the rhyme?
ThomasM
Site Admin
Posts: 231
Joined: Wed Feb 22, 2017 6:36 am

Re: problems on custom AviSynth-Node

Post by ThomasM »

they will most likely output 16bit from the decoded mp3
yes... truncated and without dithering and / or NoiseShaping in case the player did some "magic" on the sound... no more words.

Anyway - no problem for me if it is 32 bit. I was just wondering...

Thanks for your Input, emcodem!

cheers
thomas
Post Reply