I'm trying to conduct some listening tests by converting a FLAC file to opus at various bitrates. I can successfully run the command `opusenc --bitrate nnn song.flac - | mpv --no-audio-display -` without any issues. However, I thought using process substitution like this `mpv --no-audio-display <(opusenc --bitrate nnn song.flac -)` would have the same effect, but it fails. I receive error messages indicating that mpv cannot recognize the file format. Can someone help me understand what's going wrong here?
5 Answers
Unfortunately, a lot of programs don't really support process substitution properly. What happens is that with `<(...)`, bash creates a pipe and gives mpv a file descriptor to read from. If mpv treats it like a regular file instead of a stream, it can fail. It probably has the capability to read from stdin, but it doesn't recognize the FIFO from the substitution.
mpv seems to try seeking when it opens a file. When you use process substitution, it ends up receiving a FIFO instead of a regular file, which could lead to those seeking issues. If it mistakenly thinks it can seek, but it can't, that's where the error comes from. When you pass a dash `-`, it knows to just read from stdin and not try to seek.
You might want to check how you're structuring the command. I think you need the dash `-` at the end of the mpv command, but it may not be necessary. Just a thought!
Thanks for the tip! But it seems like that isn't the main issue.
The two methods are fundamentally different. Using a dash to indicate stdin is telling mpv to expect input from the standard input, but with process substitution, it's making a named pipe that it might not interpret correctly. That's likely causing the discrepancy in behavior.
Wait, was the dash missing by design in your second command? That could definitely change how things work.

That makes a lot of sense! Sometimes programs don't handle those situations well.