From: Brian Foster (blf at domain utvinternet.ie)
Date: Wed 31 Jul 2002 - 02:58:05 IST
| Date: Tue, 30 Jul 2002 20:00:48 +0100
| From: Ronan Cunniffe <ronan at domain cunniffe.net>
|
|[ ... ] The whole thing is a three stage pipeline:
|
| lav2yuv capture.avi | yuvdenoise | mpeg2enc --lots-of-args...
| (100 mins) (260 mins) (236 mins)
|
| The times are cpu time for a particular segment of video.
| All compression runs use the same first two stages - 360 mins.
| Obviously, I want to do that once and send the results to lots
| of encoding processes.
|
| I did the following:
|
1| $ mkfifo f1
2| $ lav2yuv capture.avi | yuvdenoise | tee f1 | mpeg2enc blah blah &
3| $ cat f1 | mpeg2enc different blah blah
|
| And hey! It works! Until somebody dies! Yippe... oh. [ ... ]
( a winner of the Useless Use of cat(1) Award: you don't need
the `cat f1 |' in the 3rd line, a simple `<f1' will suffice. )
strange. is your tee(1) POSIX.2 conformant?
try using the GNU `tee' (e.g., `tee (GNU sh-utils) 2.0').
I assume by "someone dies" you mean one of the two `mpeg2enc's
prematurely terminates. and that, in turn, apparently causes
the other one to hang or also prematurely terminate (which you
don't want to happen) ....
see, the death of either `mpeg2enc' would eventually cause the
`tee' to be SIGPIPEd. if `tee' were a normal filter, that does
cause it to die, effectively causing the other `mpeg2enc' to
also die.
however, `tee' is not quite a normal filter.
as I recall, a POSIX.2-conforming `tee' ignores SIGPIPE so it
can continue to write(2) to the sinks. as I recall, POSIX.2
requires that a write error to one sink not prevent all the
data from being written to the other sinks. most(?) `tee's,
including GNU, also continue trying to use the "failed" sink.
upshot is a POSIX.2 `tee' would probably spit out an error
message if one of the `mpeg2enc's dies, but the remaining
one would continue to be fed data and hence run until it
either completes or dies for reasons of its own. which is
exactly what you want! so what is happening??
the point is I don't see --- off-hand and late at night ---
any reason for the above to fail (for the only definition of
"fail" which seems, to me, to make any sense) .....??
could it be yer being confused by the shell waiting only for
the 3rd line to complete? if that `mpeg2enc' finishes (dies)
well before the 2nd line, you may not realize the 2nd line is
still running ....
incidently, if your shell and system both support process
redirection, you could do the above as a one-liner. syntax
varies depending on the shell, but in bash(1) and ksh(1):
lav2yuv capture.avi | yuvdenoise | \
tee >(mpeg2enc different blah blah) | mpeg2enc blah blah
albeit that means the shell is now only waiting on the other
`mpeg2enc' (the one in the 2nd line of the original). b.t.w.,
I suspect the above also explains why POSIX.2 mandated the
not-quite-normal behaviour: process output redirection would
not work if `tee' were normal.
puzzled,
-blf-
--
«How many surrealists does it take to | Brian Foster Dublin, Ireland
change a lightbulb? Three. One calms | e-mail: blf at domain utvinternet.ie
the warthog, and two fill the bathtub | mobile: (+353 or 0)86 854 9268
with brightly-coloured machine tools.» | http://www.blf.utvinternet.ie
Stop E$$o (ExxonMobile): «Whatever you do, don't buy Esso --- they
don't give a damn about global warming.» http://www.stopesso.com
Supported by Greenpeace, Friends of the Earth, and numerous others...
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:18:07 GMT