問題描述
我在從 YouTube 視頻中提取自動字幕時遇到問題.
I'm having problems extracting automatic captions from YouTube videos.
我嘗試使用 http://video.google.com/timedtext?type=track&v=3wszM2SA12E&name=Automatic&lang=en 方法,但該方法僅適用于那些具有命名軌道的視頻.例如,這個沒有任何命名軌道(只有自動字幕)并且不會加載:rrkrvAUbU9Y
I tried using the http://video.google.com/timedtext?type=track&v=3wszM2SA12E&name=Automatic&lang=en method, but that one only works for those videos, which have named tracks. For example, this one doesn't have any named tracks (only automatic caption) and doesn't load up: rrkrvAUbU9Y
有幾個網絡應用程序可以做到這一點(例如 http://www.serpsite.com/youtube-subtitles-download-tool/ 和 http://mo.dbxdb.com/),但我需要一個腳本,因為我想用它進行研究.
There are several web-applications out there which can do it (like http://www.serpsite.com/youtube-subtitles-download-tool/ and http://mo.dbxdb.com/), but I need a script, because I want to use it for my research.
任何人都知道獲得這個的正確方法是什么?YouTube 的 API 有一些關于字幕的內容,但僅適用于注冊用戶,而上述應用程序適用于所有視頻,我懷疑它們只是從頁面中捕獲 html 代碼(盡管這也是可能的).一定有辦法……請幫忙!
Anyone has any ideas what is the correct way to get this? YouTube's API has something about captions, but only for registered users, while the apps above work for all videos and I doubt they just capture the html code from the page (although that's possible too). There must be a way... please help!
推薦答案
需要先調用另一個API:http://video.google.com/timedtext?type=list&v=3wszM2SA12E
You need to call another API first: http://video.google.com/timedtext?type=list&v=3wszM2SA12E
這將為您提供可用曲目的列表.在您的情況下,只能獲得一首曲目:id=0";名稱=自動"lang_code="en";lang_original=英語"lang_translated="英文"lang_default="true"
This will give you the list of the tracks available. In your case only one track can be obtained: id="0" name="Automatic" lang_code="en" lang_original="English" lang_translated="English" lang_default="true"
在這個特定的視頻中,我可以按名稱獲取曲目name=Automatic
:
In this particular video I could get the track by name name=Automatic
:
https://video.google.com/timedtext?type=track&v=3wszM2SA12E&name=Automatic&lang=en
但是對于另一個視頻 id=
工作正常:
But for another video id=
worked fine:
http://video.google.com/timedtext?type=track&v=zenMEj0cAC4&id=0&lang=en
http://video.google.com/timedtext?type=track&v=zenMEj0cAC4&id=0&lang=en
這篇關于從 YouTube 視頻中提取自動字幕的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!