Skip to content

Instantly share code, notes, and snippets.

@AeroNotix
Created February 22, 2016 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AeroNotix/78f9e12b365dcc2e2c59 to your computer and use it in GitHub Desktop.
Save AeroNotix/78f9e12b365dcc2e2c59 to your computer and use it in GitHub Desktop.
import time
import sys
import vlc
from datetime import datetime
def main(rtsp_stream, period=1, output='snapshot%s.png'):
player = vlc.MediaPlayer(rtsp_stream)
player.play()
time.sleep(5)
while True:
filename = (output % str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))).replace(' ', '')
player.video_take_snapshot(0, filename, 0, 0)
time.sleep(period)
if __name__ == '__main__':
if len(sys.argv) == 4:
main(sys.argv[1], period=sys.argv[2], output=sys.argv[3])
if len(sys.argv) == 3:
main(sys.argv[1], period=sys.argv[2])
if len(sys.argv) == 2:
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment