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:
target_dir /home/pi
snapshot_filename %Y%m%d-%H%M%S-snap
snapshot_interval 3600
output_pictures off
Now we configure the two ports as follows in motion.conf:
stream_port 8081
stream_localhost off
webcontrol_port 8080
webcontrol_localhost off
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:
http://192.X.X.X:8081/
In addition, you can take a snapshot each time you fetch the following URL:
http://192.X.X.X:8080/1/action/snapshot
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.