I am trying to add a feature to my web app that enables the users to create clips from embedded YouTube videos on my app without bothering going through YouTube itself. Is there any tool available? Couldn't find anything on the YouTube API docs.
I'd like to use YouTube APIs (even if other tools are available), specify the start and end of the clip, then receive the new video id as the result.
Unfortunately YouTube APIs don't give the ability to create clips.
However you can create an algorithm to create clips automatically:
To generate clips automatically, first you need to make a test clip to initialize the mechanism, but before clicking on the button Share clip
, open your web-browser developer Network
tab (Ctrl
+Shift
+E
on Firefox) and filter (if possible) XHR
then click on Share clip
. You should see a request to create_post
, right-click it and copy it as cURL.
At the end of this command there are interesting arguments:
commentText
it is the clip descriptionexternalVideoId
it is the video id you are clippingoffsetMs
is the start of the clip in millisecondsdurationMs
is the duration of the clip in milliseconds
You can freely modify these arguments to generate a clip automatically without using YouTube UI.Remove -H 'Accept-Encoding: gzip, deflate, br'
from the command in order not to have the following warning notifying us of the absence of output at the command execution:
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
Then execute the modified command, you should get a JSON response, the interesting entry of it is actions/0/shareEntityServiceEndpoint/serializedShareEntity
, as it contains a base 64 of the generated clip id and some other stuff.
The clip is the 36 length id similar to UgkxbH81RHU_yyYr1cq2oUrcVtPfTFU-Zumx
.