Menu

#219 output file header incorrect when using pipe

closed-wont-fix
nobody
None
5
2013-01-04
2012-11-02
Chaz
No

mp3 to wav conversion while using piping to output instead of writing to file doesn't work as expected

How to reproduce error:

$: sox Slipknot\ -\ Psychosocial.mp3 -t wav psychosocial2.wav
$: sox Slipknot\ -\ Psychosocial.mp3 -t wav - | cat > psychosocial.wav
$: diff psychosocial.wav psychosocial2.wav
Binary files psychosocial.wav and psychosocial2.wav differ

This should replicate with most mp3 files.

Investigating with a hex editor, it appears certain bytes which should be output as "6E" get output as "80" when piped (there may be others, that is the one which manifested first in my file). I suspect this is actually "FFFFFF80" being output as "80", with the outputs being the wrong types, but haven't confirmed.

Discussion

  • Chaz

    Chaz - 2012-11-02

    Clarification: only incorrect in header section of the wav file, data section outputs correctly.

     
  • Chaz

    Chaz - 2012-11-02
    • summary: output file incorrect when using pipe --> output file header incorrect when using pipe
     
  • Ulrich Klauer

    Ulrich Klauer - 2013-01-04

    The length of an MP3 file cannot be determined exactly beforehand. This is why the header info is wrong (or inexact, at least). When writing to a file, the WAV format handler will go back to the header when all samples have been written and fix the length information. When writing to a pipe, this is not possible.

     
  • Ulrich Klauer

    Ulrich Klauer - 2013-01-04
    • status: open --> closed-wont-fix
     

Log in to post a comment.

MongoDB Logo MongoDB