ffmpeg - Continuously stream webcam to single .jpg file (overwrite)
debian, ffmpeg, mjpeg, stream
Solution
It is possible to achieve what I wanted by using:
./mjpg_streamer -i "input_uvc.so -r 1280×1024 -d /dev/video0 -y" -o "output_http.so -p 8080 -w ./www"
...from within the mjpg_streamer's directory. It will do all the nasty work for you by displaying the stream in the browser when using the address: http://{IP-OF-THE-SERVER}:8080/ It's also light-weight enough to run on a Raspberry Pi.
Here is a good tutorial for setting it up.
Thanks for the help!
Problem
I have installed ffmpeg and mjpeg-streamer. The latter reads a .jpg file from /tmp/stream and outputs it via http onto a website, so I can stream whatever is in that folder through a web browser. I wrote a bash script that continuously captures a frame from the webcam and puts it in /tmp/stream: ``` while true do ffmpeg -f video4linux2 -i /dev/v4l/by-id/usb-Microsoft_Microsoft_LifeCam_VX-5000-video-index0 -vframes 1 /tmp/stream/pic.jpg done ``` This works great, but is very slow (~1 fps). In the hopes of speeding it up, I want to use a single ffmpeg command which continuously updates the .jpg at, let's say 10 fps. What I tried was the following: ``` ffmpeg -f video4linux2 -r 10 -i /dev/v4l/by-id/usb-Microsoft_Microsoft_LifeCam_VX-5000-video-index0 /tmp/stream/pic.jpg ``` However this - understandably - results in the error message: ``` [image2 @ 0x1f6c0c0] Could not get frame filename number 2 from pattern '/tmp/stream/pic.jpg' av_interleaved_write_frame(): Input/output error ``` ...because the output pattern is bad for a continuous stream of images. Is it possible to stream to just one jpg with ffmpeg? Thanks...