Skip to content

Instantly share code, notes, and snippets.

@zacharydenton
Created January 18, 2011 17:30
Show Gist options
  • Save zacharydenton/784799 to your computer and use it in GitHub Desktop.
Save zacharydenton/784799 to your computer and use it in GitHub Desktop.
FLAC anomalies...
This works:
flac -dc -- "/home/zdenton/test/The Pretty Things - S F Sorrow [24-96]/08. The Journey.flac" | sox -t wav - -b 16 -t wav - rate 44100 dither | flac --best -T "TITLE=The Journey" -T "ALBUM=S.F. Sorrow" -T "ALBUM=The Pretty Things" -T "TRACKNUMBER=08" -T "GENRE=" -T "DATE=1968-12" -o "/home/zdenton/test/The Pretty Things - S F Sorrow [16-44] (FLAC)/08. The Journey.flac" - 2>&1
This doesn't:
flac -dc -- "/home/zdenton/test/The Pretty Things - S F Sorrow [24-96]/12. Old Man Going.flac" | sox -t wav - -b 16 -t wav - rate 44100 dither | flac --best -T "TITLE=Old Man Going" -T "ALBUM=S.F. Sorrow" -T "ALBUM=The Pretty Things" -T "TRACKNUMBER=12" -T "GENRE=" -T "DATE=1968-12" -o "/home/zdenton/test/The Pretty Things - S F Sorrow [16-44] (FLAC)/12. Old Man Going.flac" - 2>&1
The latter stops at around 99% and says:
-: WARNING: skipping unknown sub-chunk '��/' (use --keep-foreign-metadata to keep)
-: ERROR: unexpected EOF
I can't use --keep-foreign-metadata since I'm encoding from stdin.
UPDATE:
The error goes away if I write the output from SoX to a temporary WAV file instead of stdout.
flac -dc -- "/home/zdenton/test/The Pretty Things - S F Sorrow [24-96]/12. Old Man Going.flac" | sox -t wav - -b 16 -t wav - rate 44100 dither > "/home/zdenton/test/The Pretty Things - S F Sorrow [24-96]/12. Old Man Going.flac.wav"; flac --best -T "TITLE=Old Man Going" -T "ALBUM=S.F. Sorrow" -T "ALBUM=The Pretty Things" -T "TRACKNUMBER=12" -T "GENRE=" -T "DATE=1968-12" -o "/home/zdenton/test/The Pretty Things - S F Sorrow [16-44] (FLAC)/12. Old Man Going.flac" - 2>&1 < "/home/zdenton/test/The Pretty Things - S F Sorrow [24-96]/12. Old Man Going.flac.wav"; rm "/home/zdenton/test/The Pretty Things - S F Sorrow [24-96]/12. Old Man Going.flac.wav"
@moomin
Copy link

moomin commented Jan 8, 2012

I'm experiencing the same issue.
Specifying raw output for sox and explicit format options for flac encorder seems to work:
flac -s -d -c $IN | sox - -S -D -r $SAMPLE_RATE -b $BPS -t raw -e signed-integer - | flac -s -8 -o $OUT --endian=little --channels=2 --sign=signed --bps=16 --sample-rate=44100 -

Though it adds some limitations (e.g. you'll have to add a seektable manually after encoding) because flac doesn't know size of the input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment