如何使用 Youtube API 为 Youtube 视频添加字幕?

编程入门 行业动态 更新时间:2024-10-26 20:23:42
本文介绍了如何使用 Youtube API 为 Youtube 视频添加字幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

是否可以使用 Google Youtube API v3Youtube 视频添加字幕(重要条件 - 对于视频不是所有者)?

任务:使用 Google APIs Client Library for JavaScript 添加所选语言的自定义字幕.

(Google maps API 允许在他们的地图中添加自定义Markers(例如),也许当我们有一个解决subtitles是在谈论 Youtube API?)

解决方案

Google 称它们为字幕",API 部分称为 YouTube API v2.0 – 字幕.

<块引用>

请注意以下执行字幕相关的要求API 操作:

字幕仅适用于 API 版本 2.视频的字幕只能由该视频的所有者创建、检索、修改和删除.执行这些操作视频,您必须提交经过身份验证的 API 请求,视频的所有者是登录用户.因此,API 请求字幕操作必须包含格式正确的授权标题.创建 (POST)、更新 (PUT) 或删除 (DELETE) 字幕的请求必须使用 X-GData-Key 标识您的开发者密钥请求标头或关键请求参数.

这意味着,您可以使用 API 添加字幕,但您需要拥有对该视频的所有者访问权限.这是一项严格的政策,因此您不会在任何视频上显示错误"的字幕,例如,在视频中显示与实际内容不同的翻译.

您只能通过将视频放入容器中来解决此问题,并将您自己的文本覆盖在视频上从而模拟字幕.

Is it possible to add subtitles to Youtube video using Google Youtube API v3 (important condition - for video's not owner)?

Task: add custom subtitles in selected language using the Google APIs Client Library for JavaScript.

(Google maps API allows add, custom Markers (for example) to their maps, maybe there is a solution for subtitles when we're talking about Youtube API?)

解决方案

Google are calling them "captions" and API section is called YouTube API v2.0 – Captions.

Please note the following requirements for executing caption-related API operations:

Captions are only available for API version 2. Captions for a video can only be created, retrieved, modified and deleted by the owner of that video. To perform these operations for a video, you must submit authenticated API requests for which the video's owner is the logged-in user. Accordingly, API requests for caption operations must contain a properly formatted Authorization header. Requests to create (POST), update (PUT) or delete (DELETE) captions must identify your developer key using either the X-GData-Key request header or the key request parameter.

That means, that you can add captions with API, but you need to have owner access to that video. It is strict policy, so that you won't show "wrong" captions on any video, for example, that show different translation of content in video, than there actually is.

You can only hack around this, by putting video inside container, and overlay your own text over video thus simulating captions.

这篇关于如何使用 Youtube API 为 Youtube 视频添加字幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 10:04:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/935685.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   字幕   视频   API   Youtube

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!