Log in

View Full Version : wav2w64 tool to convert wav to w64


tebasuna51
1st February 2017, 22:50
There are tools to do this job, but this can be used like a 'pipe' filter to work between other tools.

For instance Sox can read and write wav files greater than 4 GB, but not output w64 files.

Ffmpeg don't accept wav files greater 4 GB and this:
EDIT: I was wrong, see https://forum.doom9.org/showthread.php?p=1795599#post1795599

sox --norm --ignore-length big.wav -t wav - | ffmpeg -i - ...

obtain a truncated output.

But this work for me:

sox --norm --ignore-length big.wav -t wav - | wav2w64 - - | ffmpeg -i - ...

In order to know the performance I make a test between:

eac3to input stdout.w64 | ffmpeg -i - -acodec ac3 -ab 448k test1.ac3

and

eac3to input stdout.wav | wav2w64 - - | ffmpeg -i - -acodec ac3 -ab 448k test2.ac3

The second encoder time was increased in only a 3%.

sneaker_ger
1st February 2017, 22:59
Excuse my ignorance but how is this possible? How does wav2w64 know how big the wav file/pipe will be in order to construct a correct w64 header? Does it create some bogus header (>> anything you use in practice)?

tebasuna51
2nd February 2017, 00:38
Yep.

1) If input is a file < 4 GB the length fields in wav header are respected and traslated to w64 header.

2) If input is a file > 4 GB or a 'piped' wav, the w64 header length fields are filled with values near 1 TB.

The stdin from ffmpeg finish the job without error when finish the input data, even if don't reach the expected size.
But finish the job also when the expected size is reached.

The soft than have parameters like --ignore-length (sox, flac, oggenc, qaac, ...) or -readtoeof (Aften) do the same but ignore size length and continue always until EOF.

If output is a w64 file the file is re-open and wav2w64 modify the header with the counted data transmitted.

richardpl
2nd February 2017, 09:01
FFmpeg wav demuxer have -ignore_length option too.

tebasuna51
2nd February 2017, 12:53
Thanks richardpl

Well, maybe I lose my time making this tool.

I search the parameter ignore_length in https://www.ffmpeg.org/ffmpeg-all.html (and in links to ffmpeg ffplay, ffprobe, ffserver, ffmpeg-utils, ffmpeg-scaler, ffmpeg-resampler, ffmpeg-codecs, ffmpeg-bitstream-filters, ffmpeg-formats, ffmpeg-devices, ffmpeg-protocols, ffmpeg-filters) without success.

Please show me if there are some ffmpeg docs about that.

Finally I found a reference in ffmpeg -h full
WAV demuxer AVOptions:
-ignore_length <boolean> .D...... Ignore length (default false)

And I try:
sox --norm --ignore-length big.wav -t wav - | ffmpeg -ignore_length true -i - -acodec ac3 -ab 448k test.ac3

And work ok. Some messages:

sox WARN wav: Length in output .wav header will be wrong since can't seek to fix it

ffmpeg version ...
Input #0, wav, from 'pipe:':
Duration: 00:41:25.51, bitrate: N/A
Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, 5.1, s32 (24 bit), 6912 kb/s
Output #0, ac3, to 'test.ac3':
Stream #0:0: Audio: ac3, 48000 Hz, 5.1, fltp (24 bit), 448 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s24le (native) -> ac3 (native))
size= 395029kB time=02:00:23.38 bitrate= 448.0kbits/s speed=51.3x
video:0kB audio:395029kB ...

The expected duration is less than the final time encoded.
Then ffmpeg can continue until EOF with -ignore_length true

I was wrong, but at least I know one more thing about ffmpeg.