Project

webvtt

0.01
No commit activity in last 3 years
No release in over 3 years
WEBVTT file parser in Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.5.0
>= 2.5.0
>= 0
 Project Readme

WEBVTT FILE parser for Ruby

Parse WebVTT files with Ruby. The main goal is just to extract the text out with start and end times. The parsing does not conform the WebVTT specification at this point.

Build Status

Story

We were creating WebVTT files to enable closed captions for HTML5 video. We wanted to reuse this work to embed the transcript in the video player page to increase SEO and allow for jumping to sections of the video.

Install

gem install webvtt

Usage

Based on this WebVTT:

WEBVTT

1
00:00:00.000 --> 00:00:03.000 D:vertical A:start
I grew up in Eastern North Carolina, <b>Edgecombe</b> County

2
00:00:03.300 --> 00:00:07.800 A:start
on a tobacco and dairy farm outside of Tarboro.

You can do the following:

require 'webvtt'
vtt = Webvtt::File.new('path/to/file.vtt')
vtt.cues.class    #=> Webvtt::Cue
vtt.cues[0].start #=> '00:00:00.000'
vtt.cues[0].end   #=> '00:00:03.000'
vtt.cues[0].identifier #=> '1'
vtt.cues[0].settings   #=> 'D:vertical A:start'
vtt.cues[0].text       #=> 'I grew up in Eastern North Carolina, <b>Edgecombe</b> County'

Author

Jason Ronallo

License

See LICENSE