Search code examples
httppostyoutubelive-streamingyoutube-livestreaming-api

How to caption YouTube Livestreams?


YouTube is offering the possibility to send captions in a livestream as documented here. However, this guide refers to a link from Youtube Studio Classic, which is no longer existent. In the new Live Control Room, I can only find a link for subtitles which looks like

http://upload.youtube.com/closedcaption?cid=....

and does not contain the parameters like ns or sparams.

How can I provide captions with the Live Control Room? There is also some misleading information on other pages - can I just use a simple HTTP POST or do I need to buy one of the supported softwares?

If it is not possible using POST, can I use the Livestreaming API for that?


Solution

  • It works for me using below python code.

    import time
    import requests
    from datetime  import datetime
    
    word = "this is caption " + str(seq)
    
    ytlink = "http://upload.youtube.com/closedcaption?cid=xxx-xxx-xxx-xxx="+str(seq)
    
    post_fields = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + ' \n' + word + '\n' 
    
    headers = {'content-type': 'text/plain'}
    r = requests.post(url=ytlink, data=post_fields.encode('utf-8'), headers=headers)
     
    print(ytlink)
    print(r.text)
    

    Basically, others won't be required anymore.