def Instagramm(username, password): ig = InstagramAPI(username, password) ig.login() islemler = int( input(""" 1-Kullanıcı yayın akışı görüntüle 2-Canlı Yayın Başlat """)) if (islemler == 1): ig.getTimeline() elif (islemler == 2): import subprocess FILE_PATH = '/path/to/video/file' PUBLISH_TO_LIVE_FEED = False SEND_NOTIFICATIONS = False api = InstagramAPI(username, password, debug=False) assert api.login() # first you have to create a broadcast - you will receive a broadcast id and an upload url here assert api.createBroadcast() broadcast_id = api.LastJson['broadcast_id'] upload_url = api.LastJson['upload_url'] # we now start a boradcast - it will now appear in the live-feed of users assert api.startBroadcast(broadcast_id, sendNotification=SEND_NOTIFICATIONS) ffmpeg_cmd = "ffmpeg -rtbufsize 256M -re -i '{file}' -acodec libmp3lame -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v baseline -s 720x1280 -bufsize 6000k -vb 400k -maxrate 1500k -deinterlace -vcodec libx264 -preset veryfast -g 30 -r 30 -f flv '{stream_url}'".format( file=FILE_PATH, stream_url=upload_url.replace( ':4343', ':80', ).replace('rtmps://', 'rtmp://'), ) print(" Ctrl+C yaparak yayını sonlandırabilirsiniz") try: subprocess.call(ffmpeg_cmd, shell=True) except KeyboardInterrupt: print('Stop Broadcasting') assert api.stopBroadcast(broadcast_id) print('Yayın sona erdi') if PUBLISH_TO_LIVE_FEED: api.addBroadcastToLive(broadcast_id) print('Added Broadcast to LiveFeed')
assert api.login() # first you have to create a broadcast - you will receive a broadcast id and an upload url here assert api.createBroadcast() broadcast_id = api.LastJson['broadcast_id'] upload_url = api.LastJson['upload_url'] # we now start a boradcast - it will now appear in the live-feed of users assert api.startBroadcast(broadcast_id, sendNotification=SEND_NOTIFICATIONS) ffmpeg_cmd = "ffmpeg -rtbufsize 256M -re -i '{file}' -acodec libmp3lame -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v baseline -s 720x1280 -bufsize 6000k -vb 400k -maxrate 1500k -deinterlace -vcodec libx264 -preset veryfast -g 30 -r 30 -f flv '{stream_url}'".format( file=FILE_PATH, stream_url=upload_url.replace( ':443', ':80', ).replace('rtmps://', 'rtmp://'), ) print("Hit Ctrl+C to stop broadcast") try: subprocess.call(ffmpeg_cmd, shell=True) except KeyboardInterrupt: print('Stop Broadcasting') assert api.stopBroadcast(broadcast_id) print('Finished Broadcast') if PUBLISH_TO_LIVE_FEED: api.addBroadcastToLive(broadcast_id) print('Added Broadcast to LiveFeed')
api = InstagramAPI(USERNAME, PASSWORD, debug=False) assert api.login() # first you have to create a broadcast - you will receive a broadcast id and an upload url here assert api.createBroadcast() broadcast_id = api.LastJson['broadcast_id'] upload_url = api.LastJson['upload_url'] # we now start a boradcast - it will now appear in the live-feed of users assert api.startBroadcast(broadcast_id, sendNotification=SEND_NOTIFICATIONS) ffmpeg_cmd = "ffmpeg -rtbufsize 256M -re -i '{file}' -acodec libmp3lame -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v baseline -s 720x1280 -bufsize 6000k -vb 400k -maxrate 1500k -deinterlace -vcodec libx264 -preset veryfast -g 30 -r 30 -f flv '{stream_url}'".format( file=FILE_PATH, stream_url=upload_url.replace(':443', ':80', ).replace('rtmps://', 'rtmp://'), ) print("Hit Ctrl+C to stop broadcast") try: subprocess.call(ffmpeg_cmd, shell=True) except KeyboardInterrupt: print('Stop Broadcasting') assert api.stopBroadcast(broadcast_id) print('Finished Broadcast') if PUBLISH_TO_LIVE_FEED: api.addBroadcastToLive(broadcast_id) print('Added Broadcast to LiveFeed')