Alex Witsil
Alex Witsil

Reputation: 862

saving frames from webcam stream

I would like a routine that systematically extracts and saves the frames from webcam footage to a local directory on my personal computer.

Specifically, I am trying to save frames from the webcam at Old Faithful geyser in Yellowstone Natl. Park. (https://www.nps.gov/yell/customcf/geyser_webcam_updated.htm)

Ideally, I would like to:

  1. be able to control the rate at which frames are downloaded (e.g. take 1 frame every minute)
  2. use FFMPEG or R
  3. Save the actual frame and not a snapshot of the webpage

Despite point 3 above, I've tried simply taking a screenshot in R using the package webshot:

library(webshot)
i=1
while(i<=2) { 
webshot('https://www.nps.gov/yell/customcf/geyser_webcam_updated.htm',delay=60,paste(i,'.png',sep=""))

i=i+1
}

However, from the above code I get these two images:

enter image description here enter image description here Despite the delay in the webshot() function (60 seconds) the two images are the same not to mention the obvious play button in the middle. This method also seems a bit of a hack as it is saving a snapshot of the website and not the frames themselves.

I am certainly open to to using more appropriate command line tools (I am just unsure of what they are). Any help is greatly appreciated!

Upvotes: 1

Views: 381

Answers (1)

Gyan
Gyan

Reputation: 93008

The source code of the URL shows, under the video tag

<source type="application/x-mpegurl" src="//56cf3370d8dd3.streamlock.net:1935/nps/faithful.stream/playlist.m3u8">

The src identifies a HLS playlist. So, you can then run ffmpeg periodically to get an image output like this:

ffmpeg -i https://56cf3370d8dd3.streamlock.net:1935/nps/faithful.stream/playlist.m3u8 -vframes 1 out.png

Upvotes: 2

Related Questions