'How to record livestream with audio with python?
I want to use python to record a livestream with video and audio. The following code snippet is a complete working example (which might work only in Grmany, or by VPN) which I can use to record a livestream, but the resulting file is only the video without the audio:
import time
import requests
from seleniumwire import webdriver
def download_stream(url):
r1 = requests.get(url, stream=True)
with open('testvid.mp4','ab') as f:
for chunk in r1.iter_content(chunk_size=1024):
f.write(chunk)
# Create a new instance of the Chrome driver
driver = webdriver.Chrome()
# Go to the Google home page
driver.get('https://www.zdf.de/live-tv')
# Access requests via the `requests` attribute
tslist = []
while True:
for request in driver.requests:
if request.url.endswith(".ts"):
if request.url not in tslist:
tslist.append(request.url)
download_stream(request.url)
What do I have to change to also record the audio of the livestream in sync with the video stream?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
