Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
The WebVTT format is a standard captionning format used for HTML5 videos and HTTP Live Streaming (HLS).
Add this line to your application's Gemfile:
gem 'webvtt-ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install webvtt-ruby
To parse a webvtt file:
require "webvtt"
webvtt = WebVTT.read("path/sub.vtt")
webvtt.cues.each do |cue|
puts "identifier: #{cue.identifier}"
puts "Start: #{cue.start}"
puts "End: #{cue.end}"
puts "Style: #{cue.style.inspect}"
puts "Text: #{cue.text}"
puts "--"
end
You can also convert an SRT file to a standard WebVTT file:
webvtt = WebVTT.convert_from_srt("path/sub.srt", "path/sub.vtt")
puts webvtt.to_webvtt
Segmenting is required to work with HLS videos.
WebVTT.segment("subtitles/en.vtt", :length => 10, :output => "subtitles/en-%05d.vtt", :playlist => "subtitles/en.m3u8")
It will also generate the playlist in m3u8
:
#EXTM3U
#EXT-X-TARGETDURATION:17
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:13,
en-00000.vtt
#EXTINF:17,
en-00001.vtt
#EXTINF:12,
en-00002.vtt
#EXT-X-ENDLIST
To use the segmented webvtt files with your HLS playlist:
#EXTM3U
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="en",URI="subtitles/en.m3u8"
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=300000,SUBTITLES="subs"
demo-300000.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=600000,SUBTITLES="subs"
demo-600000.m3u8
You can also segment webvtt files using the command line webvtt-segmenter
:
$ webvtt-segmenter -i subtitles/en.vtt -t 10 -m subtitles/en.m3u8 -o "subtitles/en-%05d.vtt"
$ webvtt-segmenter -h
Usage: bin/webvtt-segmenter [--arg]
-i, --input [PATH] WebVTT or SRT file
-b, --base-url [URL] Base URL
-t, --target-duration [DUR] Duration of each segments. Default: 10
-o, --output [PATH] Path where WebVTT segments will be saved. Default: fileSequence-%05d.vtt
-m, --playlist [PATH] Path where the playlist in m3u8 will be saved. Default: prog_index.m3u8
webvtt-ruby
was written in a few hours because there was no open source tool to segment webvtt files. It's not perfect at all but it does the job.
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)Bruno Celeste
FAQs
Unknown package
We found that webvtt-ruby demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.