Skip to content

Webcam audio access Notes

Thor Whalen edited this page Oct 25, 2021 · 1 revision

APIs

Windy

Windy provides a large repository of webcams worldwide. An example of accessing the preview image of a webcam is shown below, and the documentation can be found here.

import requests
from PIL import Image

WINDY_API_KEY = 'ENTER_YOUR_API_KEY_HERE'
url = 'https://api.windy.com/api/webcams/v2/list/webcam=1182187198?show=webcams:video' + f'&key={WINDY_API_KEY}'
r = requests.get(url)
results = r.json()['result']
image_url = results['webcams'][0]['image']['daylight']['preview']
im = Image.open(requests.get(image_url, stream=True).raw)

skicams

skicams also provides a large repository of webcams worldwide, but only provides a recent image from the webcam. An example of accessing the image for a webcam is show below.

import requests
from PIL import Image

url = "https://makevoid-skicams.p.rapidapi.com/cams.json"

SKYCAMS_API_KEY = 'ENTER_YOUR_API_KEY_HERE'
headers = {
    'x-rapidapi-key': SKYCAMS_API_KEY,
    'x-rapidapi-host': "makevoid-skicams.p.rapidapi.com"
    }

response = requests.request("GET", url, headers=headers)

image_url = response.json()['1']['cams']['1']['url']
im = Image.open(requests.get(image_url, stream=True).raw)

Ziggeo

Ziggeo is another API that allows access to public webcams. The documentation can be found here

Python bindings

aiortc for WebRTC

aiortc provides python bindings for WebRTC, which is designed to enable web apps/site to capture and stream audio/video media. aiortc allows for the implementation of WebRTC in python, but it still requires a server to be hosted to utilize the functionality.

ffmpeg-python for FFmpeg

ffmpeg-python provides python bindings for FFmpeg, which is a software suite for handing video, audio, and other multimedia files and streams. ffmpeg-python allows for the usage of FFmpeg with python. While ffmpeg-python has lots of useful functionality, such as allowing for the filtering of only the audio-portion of an AV recording, or combining separate audio and visual threads into one recording (this could be done by using pyaudio for the audio thread and opencv-python for the visual thread), it does not have any functionality for accessing the webcam/microphone for recording.

Clone this wiki locally