Watching and Simultaneously Saving Video in mplayer - is it possible?

This is a question I've posed in the Ubuntu forums, but I haven't found the answer yet.

I've got a great little IP security camera - the Y-Cam. It's Internet accessible, so it can email me photos of any suspicious behaviour. It will also stream video and audio to a number of devices - including mobiles.

Under Linux, it's very easy to get the video and audio via mplayer.


And we get this rather spiffy video playing.
ycam stream mplayer

In fact, there are a number of streams available (depending on camera), including RTSP and 3GP. The ASF stream seems the most Linux friendly.

It's also possible to save the video to a file - so if you catch a miscreant in the act of pilfering, you have video and audio evidence.

    -dumpstream -dumpfile ycam.asf

You now have a file which can be played back.

What I can't seem to work out is how to do the two together. I want a command which will show me the video and at the same time save it to disk.

So, fearless Internet commentors - any helpful suggestions?


4 thoughts on “Watching and Simultaneously Saving Video in mplayer - is it possible?

  1. Terence, you can use a pipe to redirect output from mplayer and capture it into a file, while it is playing on screen.

    For example:

    First, you must create a pipe:

    mkfifo ./videoPipe

    Then, you must execute a process to read stream from this pipe, and play it. Don't forgot '&' for working on background:

    cat ./videoPipe | tee -a -i video.asf | mplayer - &

    'tee' command, save the stream into a file, and send it to 'mplayer'.

    And finally, you must send data to pipe:

    mplayer -dumpstream -dumpfile ./videoPipe

  2. Wyatt8740 says:

    I would normally use ffplay, but I can confirm that mplayer will work for this purpose too. The second example is with mplayer, first with ffplay because I prefer it:

    Using ffplay, I do this to both watch and play video:

    wget -O - | tee cameravideo.avi | ffplay -

    this first uses 'wget' to start downloading the video (and the -O - to output it to stdout), then 'tee (output file name)' to copy the stdout from wget to a file on your computer, as well as to keep it passing through the pipe as well, then 'ffplay -' to make ffplay view the stream.

    In mplayer, i do this:

    wget -O - | tee cameravideo.avi | mplayer -cache 8192 -cache-min 1 -
    If you don't have mplayer cache the video first it won't play it at all in my experience, and the 'cache-min 1' means that only 1% of the cache has to be full to start playing. No matter how much I increase cache-min, mplayer always stutters when I do this, so I elected to use ffplay, but in any case, both should work to some degree.

    If you don't like the way that mplayer handles this, switch to ffplay (part of the ffmpeg package).

Leave a Reply

Your email address will not be published. Required fields are marked *