preview video while ffmpeg is recording

Daniel Armstrong daniel-r35aSzp7v8jQT0dZR+AlfA at
Mon Nov 30 18:37:33 UTC 2009

On Mon, Nov 30, 2009 at 12:58 AM, Daniel Armstrong <daniel-r35aSzp7v8jQT0dZR+AlfA at> wrote:
> Can multiple programs access the data from /dev/video0 at the same
> time? I don't know... I am trying to find that out now.
> What would be ideal would be something like... script opens a preview
> window in cvlc/mplayer/other and streams the video from /dev/video0
> then launches ffmpeg to start recording the video and saving to file
> ${OUTPUT}.
> I have the recording video part working okay in my script... just hung
> up on the preview part. It would be good to see what the camera sees
> while recording.

Just to follow up... I don't think multiple applications can be
hitting the same /dev/video[DEVICE] at the same time. You need to send
the output to a file first... It would appear I want to use the 'tee'
command to take the output of ffmpeg and save it to a video file and
pass it along to vlc for viewing. If I run:

ffmpeg -f oss -i /dev/dsp -f video4linux2 -qscale 1 -r 30 -s 320x240
-i /dev/video0 -f avi - | tee output.avi | vlc -

... it works (poorly)... that is, it takes the output of my netbook's
webcam and saves it to a video file *and* opens a preview window in
vlc while recording.

Now I say poorly because vlc has problems with buffering and sound is
kaput in the resulting video - which plays back too fast - but, hey,
those are (I hope) fine-tuning issues. I will look into what I need to
do to get it working properly.

Daniel Armstrong
The Toronto Linux Users Group.      Meetings:
TLUG requests: Linux topics, No HTML, wrap text below 80 columns

More information about the Legacy mailing list