Log in

View Full Version : Not so obvious question: stdin / stdout


OvejaNegra
30th January 2009, 13:04
Sorry but is not so clear for me. I googled and search here but is not clear for me yet:

What is stdin and stdout?
(i think is to send the output of one cli decoder to
one cli encoder without intermediate file)


Any example of how using it?

Lets see.. can i send mplayer output to x264? or xvid encraw?

Or besweet output to lame or nero aac enc?
Or one avs sript decoded with mplayer classic to x264?

Sorry but is not so clear for me.
I know, maybe is a stupid question but not for me.
Thanks

Dark Shikari
30th January 2009, 13:13
http://en.wikipedia.org/wiki/Standard_streams

OvejaNegra
2nd February 2009, 04:45
sorry but, now i'm more confused:
Example (what is this):
http://lists.mplayerhq.hu/pipermail/mplayer-users/2004-June/045901.html <- this seems to be about sending one aplication output to mplayer without using encoding to temporal file.


http://flac.sourceforge.net/documentation_tools_metaflac.html <- But here, seems to be something else

Now í'm even more confused.

Thanks and sorry.

lpcstr
2nd February 2009, 04:51
Why don't you tell us exactly what it is you are trying to accomplish.

J_Darnley
2nd February 2009, 12:20
A program can read what ever it likes from stdin. What the program assumes interprets the data as and what it does with that data is entirely dependant on how the program is written. A program asking questions will read responses from stdin because stdin is usually connected to the keyboard. Stdout and stderr are both usually connected to the display. Lots of programs will print progress and information on stderr even if there is not an error to report because you would not want this info to be mixed in with the data output by the program.

In the mplayer case, mplayer will read the data that is written by dvgrab. The place in memory it is written/read to/from is managed by the OS. In the metaflac case it could operate in the same way if you had a program ready to output the tag data. What I expect you could use it for (and perhaps some do) is when you don't connect it to stdout of another program. It should sit there waiting for data so you can type the tags yourself, e.g:
ARTIST=Elvis Presley
ALBUM=Greatest Hits
And so on. Although I don't know how you get it to finish, Ctrl + C perhaps.

Has this been helpful at all?

OvejaNegra
2nd February 2009, 15:02
Yes that has been helpful.

Another question: When a program (LAME, FLAC) says: Use - for reading from stdin
That means that it can read from stdout, for example, from another audio decoding tool?
How? How the command line will look?

I'm trying to automatize some things with a tool i'm making. But i was simply decoding - encoding using temporal WAV and AVI (lagarith).
But if i can connect (for example) mplayer for decoding and X264/Xvid encw for encoding, then i dont need tamporal files.
That's what i'm trying to do.


Thanks to all.

Guest
2nd February 2009, 15:06
Another question: When a program (LAME, FLAC) says: Use - for reading from stdin
That means that it can read from stdout, for example, from another audio decoding tool? How? How the command line will look? Yes. There is a CLI operator called the pipe that connects standard out to standard in:

source_program | sink_program

It has the same effect as this, but without needing the tmp file:

source_program > tmp
sink_program < tmp

http://en.wikipedia.org/wiki/Pipeline_(Unix)

OvejaNegra
3rd February 2009, 17:52
AHH!!!! !!!!!!!!!!!!!!!!!!!!!!!!! (!!!!!!!!!!!!!!!!!!!!)
Yes, that's totally clear!!

THANKS!!

Now a more deep question:
For example (just a basic example): If the flac tool can decode a flac to a WAV file, end the LAME encoder can encode the same WAV without problems, that means that both tools will work in "piped mode" or there are other considerations?

Thanks to all.

Guest
3rd February 2009, 19:01
As long as the source can send its output to stdout (it may not be able to) and the sink can take its input from stdin (it may not be able to) then it should work. You may also have to disable any write and read mappings that may alter the data on input and/or output (set raw mode for stdin/stdout IO).

J_Darnley
4th February 2009, 00:20
`flac -ds -o - "D:\Music\Gandalf's Fall Final.flac" | lame -V4 - "D:\Music\Gandalf's Fall Final.mp3"` works just fine and there is no need to mess with raw modes for either flac or lame.

OvejaNegra
4th February 2009, 17:35
PERFECT!!!
Thanks to all!!