Log in

View Full Version : Long audio fails only when piping to libopus


SamKook
8th November 2022, 08:41
I was working with a 6h29m audio track for a video and my usual workflow uses avs2pipemod to pipe the audio to the encoder but this time, it failed after 4% which is a first for me.

After a bunch of testing, I realized 32 or 64bit didn't matter, it only happened to libopus(nero aac worked fine) and only when piping(feeding ffmpeg the avs script directly worked fine too).

I was wondering if it's a known limitation, me messing up or an actual bug.

An easy way to recreate the issue is with a blankclip like this:
BlankClip(length=1342178, audio_rate=48000, channels=2, fps=60, width=720, height=576, color=$000000)

And something like this for the piping:
"C:\Progs\avs2pipemod\avs2pipemod64.exe" -wav "test.avs" | "C:\Progs\opus-tools-0.2-opus-1.3.1\opusenc.exe" --quiet --vbr --bitrate 64 - "test.opus"

This is what I get:
avs2pipemod[info]: writing 22369.633 seconds of 48000 Hz, 665719930882 channel audio.
avs2pipemod[info]: total elapsed time is 0.001 sec.
avs2pipemod[error]: only wrote 1012 of 1073742400 samples.

If you set the blank clip to 1 less length(1342177), it'll work fine, I made sure to find the edge of it for the test.


Edit: After chatting with a very helpful person on opus IRC channel, the issue seems to be that I was using the wav option(also tried extwav) and opus doesn't support wav files bigger than 4GB which is almost certainly what the blankclip would produce since my original file was 4.27GB.
If I use rawaudio instead when piping and use the raw switch for opusenc it does work perfectly fine.

tebasuna51
8th November 2022, 13:23
... opus doesn't support wav files bigger than 4GB...

Opusenc support them but you need add the parameter --ignorelength to force ignore the data length in wav header, a 32 bit field than have a wrong data (the overflow over 4 GB when the wav is biger).

Checked without problem your test.avs

"avs2pipemod64.exe" -wav "test.avs" | "opusenc.exe" --ignorelength --quiet --vbr --bitrate 64 - "test.opus"

Audio
Format : Opus
Duration : 6 h 12 min

The same or equivalent parameter is needed for many encoders: OggEnc2, NeroAacEnc, qaac, fhgaacenc, ffdcaenc, flac, ...

SamKook
8th November 2022, 20:38
You're right, I should have paid more attention to the neroaac command when I tested with it and it worked. I just reused my old command but it does have ignorelength specified in it.

I wonder what's the difference between that and just using raw instead, there's doesn't seem to be a need to specify anything either way other than tell the encoder it's raw.

tebasuna51
8th November 2022, 21:53
The wav header say: Samplerate, Numchannels, Bitdepth (and ChannelMask with WAVEFORMATEXTENSIBLE header)

That data must be send when using raw

SamKook
9th November 2022, 10:29
I see. The defaults just happen to be the same as my source in this case so just using --raw worked without specifying anything else.