install dulu python dan ffmpeg
pip install youtube-dl
lalu upgrade dan install streamlink
pip install --upgrade youtube-dlpip install streamlink
bikin file python restream.py
import sysimport subprocessrtmp_url = 'rtmp://a.rtmp.youtube.com/live2'stream_key = 'YOUR_STREAM_KEY'def get_streaming_url(youtube_video_url):command = ['streamlink',youtube_video_url,'best','--stream-url']result = subprocess.run(command, stdout=subprocess.PIPE, text=True)return result.stdout.strip()def restream_youtube(youtube_video_url):youtube_url = get_streaming_url(youtube_video_url)destination_url = rtmp_url + '/' + stream_keycommand = ['ffmpeg','-re','-i', youtube_url,'-c:v', 'copy','-c:a', 'copy','-f', 'flv',destination_url]subprocess.run(command)if __name__ == "__main__":youtube_video_url = sys.argv[1]restream_youtube(youtube_video_url)
jalankan perintah ini untuk mencobanya
python3 stream.py "https://www.youtube.com/watch?v=YOUR_VIDEO_ID"