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

flac -t output not readily greppable #196

Open
sneak opened this issue Mar 4, 2020 · 7 comments
Open

flac -t output not readily greppable #196

sneak opened this issue Mar 4, 2020 · 7 comments

Comments

@sneak
Copy link

sneak commented Mar 4, 2020

It seems to me that flac -t should suppress the warranty/credits/version output, much like shasum -c, or at least put the noise to a different fd than the meaningful output. Perhaps the warranty/credits could go to stderr (to be seen by the user) and the real output could go to stdout.

It seems that it should also skip the percentage count-up in the event that stdout is not a tty.

@sneak
Copy link
Author

sneak commented Mar 4, 2020

Also, the -t output should probably only output a single line per file. Why is it wrapping?


3707 There Are Things.flac: ok
3419 All I Need.flac: ok
3421 Ain't No Mountain High Enough.flac: ok
3501 Chained.flac: ok
3320 World So Wide, Nowhere to Hide (From Your Heart).flac:
ok
3604 One Way Out.flac: ok
3508 More Love.flac: ok
3317 I Got a Feeling.flac: ok
3403 Here I Am Baby.flac: ok
3728 Change What You Can.flac: ok
3615 The Beginning of the End.flac: ok
3607 You've Made Me So Very Happy (promo version).flac: ok
3410 Just Ain't Enough Love.flac: ok
3309 Till Johnny Comes.flac: ok
3504 For All We Know.flac: ok
3612 You Keep Running Away.flac: ok
3315 Hey Love.flac: ok
3511 I Understand My Man.flac: *** Got error code 2:FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH


3511 I Understand My Man.flac: ERROR while decoding data
                               state = FLAC__STREAM_DECODER_ABORTED
3622 I'm Wondering (alternate mix).flac: ok
3609 You've Made Me So Very Happy.flac: ok
3318 Bernadette [Commercial Version].flac: ok
3418 The Day You Take One (You Have to take the Other).flac:
ok
3515 You're My Everything.flac: ok

flac 1.3.3
Copyright (C) 2000-2009  Josh Coalson, 2011-2016  Xiph.Org Foundation
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

3614 From Head to Toe.flac: ok
3613 If You Don't Want My Love.flac: ok
3316 Bernadette [Promo Version].flac: ok
3621 Every Time I See You I Go Wild.flac: ok
3415 I Wonder Why (Nobody Loves Me).flac: ok
3624 Don't Send Me Away.flac: ok
3714 Come See About Me.flac: ok
3319 Gonna Give Her All the Love I've Got.flac: ok

I'm using find . -type f -iname '*.flac' -print0 | xargs -0 -n 50 -P 1 flac -t 2>&1 | tee ~/checklog.txt.

I can't use -n 1 -P 64 because flac outputs part of the line before the check, does the check, then outputs the 'ok'. When not connected to a tty, it really should do a single write call with the final results, pass or fail, on a single line. The current behavior is fine for when connected to a tty, but for scripts it makes a huge mess when running in parallel.

@sneak
Copy link
Author

sneak commented Mar 4, 2020

It seems that --silent is helpful here but the docs don't mention that --silent will still print errors when using -t, I had to discover that myself via testing.

@sneak
Copy link
Author

sneak commented Mar 4, 2020

It would also be cool if it could print the full file path argument as passed to flac and not just the basename.

@sneak
Copy link
Author

sneak commented Mar 22, 2020

sneak@nostromo:/Volumes/EXT/tmp/beetimport/one/Alice Deejay - discography$ find . -type f -iname '*.flac' -print0 | xargs -0 -n 1 -P 64 flac --silent -t 2>&1 | tee ./checklog.txt
02 - Alice Deejay - Better Off Alone (Vocal Clubmix).flac: *** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC
*** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC

02 - Alice Deejay - Better Off Alone (Vocal Clubmix).flac: ERROR while decoding data
                                                           state = FLAC__STREAM_DECODER_ABORTED
sneak@nostromo:/Volumes/EXT/tmp/beetimport/one/Alice Deejay - discography$ ls
Alice Deejay - 1998 Alice Deejay - 2000 Alice Deejay - 2011 Alice Deejay -1999  checklog.txt
sneak@nostromo:/Volumes/EXT/tmp/beetimport/one/Alice Deejay - discography$

Doesn't tell me which directory it's in. Why is it truncating the argument to just the basename?

@ktmf01
Copy link
Collaborator

ktmf01 commented Jul 9, 2021

From your experiments it is clear that flac command line utility was never made to be used like this. It's more geared towards human readable output and has no options for formatting it's stderr and stdout output aside from silent and totally silent.

However, I think it would be possible to do what you want by not letting FLAC do the file walking. Would something like this be more what you're looking for?
for FILE in *.flac; do flac -t "$FILE" 2>/dev/null && echo PASS: $FILE || echo FAIL: $FILE; done
or perhaps
find . -iname *.flac | while read FILE; do flac -t "$FILE" 2>/dev/null && echo PASS: $FILE || echo FAIL: $FILE; done

@sneak
Copy link
Author

sneak commented Jul 10, 2021

From your experiments it is clear that flac command line utility was never made to be used like this.

Yeah, that's why I think this is a bug (and why I reported it). It's a unix command line tool, they are expected to operate in certain way so that they can be linked together in pipes and in scripts.

I appreciate the suggestion for wrapping the utility, I will use it when I revisit this project.

@ktmf01
Copy link
Collaborator

ktmf01 commented Jul 10, 2021

Every unix command line utility works differently. Just because something works a certain way with shasum doesn't mean it should work the same way with flac. They are very different programs. What you're trying to do wouldn't work with ffmpeg or lame either, programs which I think are closer to flac in nature.

When using flac -t with a single file, discarding stderr and using the exit code, automation is easy and predictable. As issue #217 says, it would be even easier if different error codes would be used. flac accepts multiple input files for convenience, something many other similar command line tools (like lame for example) do not.

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

2 participants