Skip to content

Instantly share code, notes, and snippets.

@misterhay
Created June 7, 2020 22:20
Show Gist options
  • Save misterhay/4324b7339d58253da80c9cf1aee44f0a to your computer and use it in GitHub Desktop.
Save misterhay/4324b7339d58253da80c9cf1aee44f0a to your computer and use it in GitHub Desktop.
#! /usr/bin/env python3
stream_key = 'xxxx-xxxx-xxxx-xxxx'
recording_path = '/home/username/Videos'
ffmpeg_path = ''
print("If you haven't started the recording already, press Ctrl-c to cancel this...")
from datetime import datetime
from pathlib import Path
import os
# find the newest file in the folder
p = Path(recording_path)
time, newest_file = max((f.stat().st_mtime, f) for f in p.iterdir())
youtube_server = 'rtmp://a.rtmp.youtube.com/live2/'
command = ffmpeg_path+'ffmpeg -re -i '+str(newest_file)+' -acodec copy -vcodec copy -f flv '+youtube_server+stream_key
os.system(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment