I followed this tutorial on making RI a webcam server and live stream video to laptop. I did it.

The reason I want to live stream video is get a preview of the photo I am about to take, or see the video while I am recording it.

I am using a USB camera. I know to record a video you use the command:

ffmpeg -f video4linux2 -r 25 -s 640x480 -i /dev/video0 nameofmyvideo.mp4

But it said "Error selecting input 0 VIDIOC_S_INPUT: Device or resource busy". I am guess because it's live streaming. I have not idea what the message means.

Now, how to record a video while the camera is live streaming?


1 Answer 1


I believe you're correct, you can't access the device with 2 separate programs at once. That said, you can certainly record and view with some careful programming (my choice would be Flask web server in Python).

A quicker approach would be to use the motion and motioneye packages with the output_all enabled. You can even download a distribution ready to go to test it: https://github.com/ccrisan/motioneyeos


Type: Boolean Range / Valid values: on, off Default: off Option Topic Picture are saved continuously as if motion was detected all the time.

This feature is not meant to be the normal mode of operation. Especially not if you have the output_normal or output_motion features enabled since it will keep on saving pictures on the disk and you will soon run out of disk space. So be careful with this command.

If your frame rate is 10 pictures per second motion will save 10 new picture pr second until the disk is full.

It does all the normal actions that are done when motion is detected. It saves pictures on the harddisk, execute external scripts, etc as fast as the frame rate of the camera. So it is probably a good idea to run with a low framerate when using this feature and to not use activate all the features that saves files on the disk.

The idea of this feature is that you can turn the feature on and off for a short period of time to test or to generate continuous mpeg films when needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.