Linux – How to get mplayer to play from stdin

linuxmplayerstdinteevideo

Why doesn't this work?

cat /dev/video1 | mplayer -

If I could get that to work, then I could play & record video at the same time using 'tee' to feed mplayer and mencoder.

I want to play live video (from /dev/video1:input=1:norm=NTSC) and record it at the same time without introducing lag.

mplayer plays the video fine (no noticeable lag).

mencoder records it fine.

But I can't figure out how to "tee" the output from /dev/video so that I can feed it to both at the same time. (I know ways to encode it, then immediately play the encoded video, but that introduces too much lag).

If mplayer and mencoder would read from stdin, then I could use 'tee' to solve this.

How can I do it?

[BTW, I'd be happy with ANY solution that plays & records at the same time, as long as it doesn't add lag – I'm not wedded to mplayer. But encoding first and then playing adds lag.]

Best Answer

You need to give it some cache when playing from stdin

cat /dev/video1 | mplayer -cache 1024 -

Without that cache option you'll get the error "Seek failed Cannot seek backward in linear streams"

Related Question