import asyncio
from ffmpeg import Progress
from ffmpeg.asyncio import FFmpeg
async def main(url: str):
streamlink = await asyncio.create_subprocess_exec(
"streamlink",
"--stdout",
url,
"best",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.DEVNULL,
)
ffmpeg = FFmpeg().option("y").input("pipe:0").output("output.mp4", c="copy")
@ffmpeg.on("progress")
def on_progress(progress: Progress):
print(progress)
await ffmpeg.execute(streamlink.stdout)
if __name__ == "__main__":
asyncio.run(main(input(" > stream url: ")))