Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-w / stdout output: seems buggy #205

Open
sdaoden opened this issue Aug 7, 2024 · 4 comments
Open

-w / stdout output: seems buggy #205

sdaoden opened this issue Aug 7, 2024 · 4 comments

Comments

@sdaoden
Copy link

sdaoden commented Aug 7, 2024

Hello!
It makes a difference whether i use -w or not in respect to whether the file is understood by play(1) aka sox(1), or not. If i compare the files there is a mismatch.

  • this is regardless of whether the output file is seekable (aka i thought the length field is simply not updated in -w mode, which may well be true nonetheless -- i did not actually look at the header).

  • it must be said that ogg123 can dump to wav in a way that play(1) works.

# faad -d -q -w -f1 orlovsky_trio.aac > /tmp/au
# # no
# play -t wav /tmp/au
play FAIL formats: can't open input file `/tmp/au': invalid chunk ID found
# # no
# faad  -d -q -w -f 1 orlovsky_trio.aac | play -t wav -

# # this works:
# ogg123 -q -d wav -f - richie_havens-freedom__woodstock_1969.ogg | play -t wav -
@sdaoden
Copy link
Author

sdaoden commented Aug 22, 2024

..please allow me to reiterate.
I do have to use an "equalizer" script to get good sound, you know.
The problem is i have input files of various sort, bit rate, channels, and sample rate.
Now, "normally" i simply do, for example, "mp4play SONG.aac"

mp4play ()
{
    ( __r_d_b_x__ y "${@}";
    eval "${__x__} faad -q -w \"${__r__}\" |
                                sox -q -t raw -r 44100 -c 2 -b 16 -e signed-integer - -t alsa" )
}

but this does not work if any of sample rate, channel, and bit rate is different.
So if i go through WAV export, the WAV header will tell sox what to do.
Yet, faad fails:

$ faad -q -w -f1 orlovsky_trio.aac > /tmp/a1.wav
#?0|kent:recs.misc$ faad -q -o /tmp/a2.wav -f1 orlovsky_trio.aac
#?0|kent:recs.misc$ play /tmp/a1.wav
play WARN alsa: can't encode 0-bit Unknown or not applicable
play FAIL formats: can't open input file `/tmp/a1.wav': invalid chunk ID found
#?2|kent:recs.misc$ play /tmp/a2.wav
play WARN alsa: can't encode 0-bit Unknown or not applicable

/tmp/a2.wav:

 File Size: 55.6M     Bit Rate: 1.41M
  Encoding: Signed PCM
  Channels: 2 @ 16-bit
Samplerate: 44100Hz
Replaygain: off
  Duration: 00:05:15.14

In:1.71% 00:00:05.39 [00:05:09.75] Out:258k  [      |      ]        Clip:0
Aborted.

Ie, it makes a difference whether i use -w or not.
Further, i now added a bypass that goes via -o, but note that that fails if the decoded file size hits the 32-bit limit (what seems to be the case).
Please call back if you want another issue for that.

Anyhow, both of these are no issues for ogg123 -q, so maybe there is something you want to fix or improve.

Thank you.

@fabiangreffrath
Copy link
Collaborator

Does it help if you use the -f 2 parameter? Does it help if you add -g?

@sdaoden
Copy link
Author

sdaoden commented Aug 23, 2024

$ faad -g -q -w -f1 /x/music/recs.misc/orlovsky_trio.aac > x.wav
$ play x.wav
play WARN alsa: can't encode 0-bit Unknown or not applicable
play FAIL formats: can't open input file `x.wav': invalid chunk ID found

-f2 is raw output. Can i somehow specify the desired bit rate, channel number, sample rate?

@LP314159
Copy link

I can verify that this occurs, at least with the AAC files that I have decoded.

The "-w" option writes a corrupt WAV file to stdout, while the "-o file.wav" option writes a valid WAV file.

Analysis of output files with sndfile-info (from the libsndfile package):

faad -w file.aac > file.wav
sndfile-info file.wav

File : file.wav
Length : 70369324
RIFF : 36
WAVE
fmt : 16
Format : 0x1 => WAVE_FORMAT_PCM
Channels : 2
Sample Rate : 48000
Block Align : 4
Bit Width : 16
Bytes/sec : 192000
data : 0
Have 0 marker at position 52 (0x34).

Sample Rate : 48000
Frames : 0
Channels : 2
Format : 0x00010002
Sections : 1
Seekable : TRUE
Duration : 00:00:00.000
Signal Max : 0 (-inf dB)

*Note the data=0 and duration is 0 and signal max is 0

faad -o file.wav file.aac
sndfile-info file.wav

File : file.wav
Length : 70369324
RIFF : 70369316
WAVE
fmt : 16
Format : 0x1 => WAVE_FORMAT_PCM
Channels : 2
Sample Rate : 48000
Block Align : 4
Bit Width : 16
Bytes/sec : 192000
data : 70369280
End

Sample Rate : 48000
Frames : 17592320
Channels : 2
Format : 0x00010002
Sections : 1
Seekable : TRUE
Duration : 00:06:06.507
Signal Max : 32768 (0.00 dB)

For me, it is desirable to have output to stdout as I can then pipe the output to Alsa aplay or other software.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants