如何使用 Youtube API 为 Youtube 视频添加字幕? [英] How to add Subtitles to Youtube video using Youtube API?

查看:31
本文介绍了如何使用 Youtube API 为 Youtube 视频添加字幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆