The motion program can be used to capture a USB video-stream on a Raspberry Pi. It can also take snapshots on demand during a video-stream.
Conceptually, motion provides two web services on separate ports that you configure in motion.conf. One web service provides the video stream. The other allows you to control motion itself.
Let's first edit motion.conf to specify a snapshot filename and location to take snapshots every hour. The timestamped snapshots will be files in /home/pi:
Now we configure the two ports as follows in motion.conf:
Let's also assume that Pi is at IP address 192.X.X.X
With the above configuration, your videostream will be accessible from a browser at:
In addition, you can take a snapshot each time you fetch the following URL:
The above is the gist of what you need to do. Please take time to read the configuration parameters. They are quite numerous but you will soon find yourself experimenting with fun things like motion-triggered movies.