Last active
October 22, 2022 19:05
-
-
Save DerBunteBall/374eea6d12cd4d9632f5b374bea2e7d3 to your computer and use it in GitHub Desktop.
ffmpeg two step approach in dirty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
import json | |
import signal | |
import subprocess | |
import requests | |
from ffmpy import FFmpeg, FFRuntimeError | |
from datetime import datetime | |
def main(): | |
headers = {"X-Requested-With": "XMLHttpRequest"} | |
data = {"room_slug": sys.argv[1], "bandwidth": "high"} | |
r = requests.post("https://chaturbate.com/get_edge_hls_url_ajax/", headers=headers, data=data) | |
data = r.json() | |
url = False | |
if data["room_status"] == "public": | |
url = data["url"] | |
now = datetime.now() | |
filename = sys.argv[1] + "-" + str(now.strftime("%Y%m%d-%H%M%S")) + ".mp4" | |
filename_temp = sys.argv[1] + "-" + str(now.strftime("%Y%m%d-%H%M%S")) + ".part.mp4" | |
if url: | |
ff = FFmpeg(inputs = {url: None}, outputs = {filename_temp: "-c copy -f mpegts"}) | |
try: | |
ff.run() | |
except BaseException as e: | |
if isinstance(e, KeyboardInterrupt): | |
ff.process.kill() | |
ff_post = FFmpeg(inputs = {filename_temp: None}, outputs = {filename: "-map 0 -dn -ignore_unknown -c copy -f mp4 \"-bsf:a\" aac_adtstoasc -movflags \"+faststart\""}) | |
ff_post.run() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment