I am trying to send captions to a YouTube Live stream (in real time). None of the documentation I've found seems to be accurate.
This page seems closest: https://support.google.com/youtube/answer/6077032?&ref_topic=2853697
But it's still quite wrong. I'm going to walk through what I've done.
- Go to YouTube and click on the little grey camera in the upper right that says "Create".
- That brings up a popup and and I select "Go Live".
- That takes me to studio.youtube.com. I click on the Stream button in the upper left corner.
- Enter basic data. Feed the stream URL into OBS. All that works fine.
- Set Captions to POST Captions to URL and copy/paste the hidden URL.
- Bring everything live then navigate to the Live viewer and watch myself on about a 10-second delay.
- Start a program that loops through sending "This is a test" style captions.
They NEVER appear.
My debug statement is this:
Sending to http://upload.youtube.com/closedcaption?cid=abcd-abcd-abcd-abcd-f77s&lang=en-US&seq=364. Body: -->2021-02-10T18:08:46.609 Do not pass go. <--
That is, I'm doing a a POST to the URL in question, Content-Type is set to text/plain. The body is the date/time in Zulu, a newline, my text, and one more newline.
I'm logging this output:
2021/02/10 18:09:09,411 pid<1633> INFO:Post Caption status code: 200
2021/02/10 18:09:09,411 pid<1633> INFO:Post Caption Returned: "2021-02-10T18:09:09.392\n"
That is, YouTube is returning HTTP_OK (200) with a timestamp and nothing else. In other words, it APPEARS to be accepting the caption.
I've made sure I have Show Captions turned on inside the viewer window.
Captions never appear.
I just added the lang argument in case that was the issue -- it doesn't make a difference. I have no idea what I'm doing wrong.
And I can't find any accurate documentation. The page I linked earlier is WRONG. The URL that the website gives as I'm setting up doesn't look anything like what is documented on that page.
You would think, given that YouTube is owned by Google, that a Google search for documentation would actually return some documentation. I actually found the linked page in a StackOverflow answer.
So, questions...
Does anyone know what I might be doing wrong, or have some hints of things I can try?
Does anyone know where I can find up-to-date documentation?
To reiterate:
A. Live streaming (not uploaded video)
B. Captions do NOT appear in the YouTube player
And help or even hints is appreciated.
Here is my latest debug. Language is C++.
Post a caption: This Sending to http://upload.youtube.com/closedcaption?cid=5gb9-x5z8-szbb-ghrr-f77s&seq=50. Body: -->2021-02-20T16:38:16.610 This <-- Post a caption: is Sending to http://upload.youtube.com/closedcaption?cid=5gb9-x5z8-szbb-ghrr-f77s&seq=51. Body: -->2021-02-20T16:38:18.827 is <-- Sending to http://upload.youtube.com/closedcaption?cid=5gb9-x5z8-szbb-ghrr-f77s&seq=52. Body: -->2021-02-20T16:38:20.800
<-- Post a caption: a Sending to http://upload.youtube.com/closedcaption?cid=5gb9-x5z8-szbb-ghrr-f77s&seq=53. Body: -->2021-02-20T16:38:21.047 a <-- Post a caption: test. Sending to http://upload.youtube.com/closedcaption?cid=5gb9-x5z8-szbb-ghrr-f77s&seq=54. Body: -->2021-02-20T16:38:23.264 test. <--
Each message replies with something like this:
2021/02/20 16:37:50,555 pid<538> INFO:Post Caption status code: 200 2021/02/20 16:37:50,555 pid<538> INFO:Post Caption Returned: "2021-02-20T16:37:50.537\n"
I am applying a delta based on the date/time that YouTube sends back, and I am fairly sure that part works.
My results:
-Captions appearing inconsistently. I'm sending with a 2-second delay, and I may or may not see a caption appear.
-When they appear, they stay on the screen very briefly (roughly a 1/2 to 1 second).
-And they appear double:
This is
This is
I'm surprised that. YouTube is generating an http: instead of https:. Switching my URL very slightly changes the behavior, but not enough to matter.