webvtt | Parse WEBVTT files with Ruby | Parser library
kandi X-RAY | webvtt Summary
kandi X-RAY | webvtt Summary
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.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Parses the header and returns it .
- Adds a line to the given cue data .
- Check if given line is a single line
- Determine if the user has a VWT header .
- Removes the footer from the header .
webvtt Key Features
webvtt Examples and Code Snippets
Community Discussions
Trending Discussions on webvtt
QUESTION
I have a transcript txt file containing a WEBVTT header, line numbers, timestamps and text lines.
I want to censor only the text lines while leaving the timestamps and line numbers unaffected from censoring. So the timestamp and line number lines should be excluded from censoring (because the number "451" in timestamps or as line number will get censored if I do not skip these lines during censoring).
The transcript looks like this:
...ANSWER
Answered 2021-May-18 at 13:29You are looping all the lines, and only if the line does not contain a digit or a timestamp like format (for which I think you can just \d
to not match a line with a digit) you pass.
But this line at the end censored = profanity.censor(line)
overwrites the variable in each iteration, and the method just returns that last overwritten variable.
If you want to keep all lines, you can use a list and add all the lines to it, also the unmodified ones in the parts where you pass
, and afterwards return the list, or join the lines on a newline.
The updated part of the code might look like:
QUESTION
File:
...ANSWER
Answered 2021-Apr-26 at 17:13Negative lookaheads may be a solution.
The following replaces sequences of a single .
with .\n
but only when it's not followed by any of .
or new line (\n
), and not followed by an end-of-sequence ($
):
QUESTION
I'm trying to build a website using django where I want to host videos with subtitles. My main goal is to make my subtitles clickable so whenever a user clicks or hovers on a word they can see the meaning of that word. I'm currently using .vtt format for my subtitles.
Any ideas on how to do it?
below is the html code:
...ANSWER
Answered 2021-Apr-13 at 04:31Off the top of my head; one way of going about doing it is to make a div for your subtitles area and the arrange everything in it using flex
with wrap
and justify-center
. This div will contain ...
tags for your words.
Then, you can dynamically fill up this template for each word in each timestamp.
The templateHere's what I mean:
QUESTION
According to YouTube's documentation on subtitle formats, it supports positioning captions with the W3C's WebVTT format, and this seems to be evidenced out in the wild: most videos I've seen using positioning - including this test video and this music video - use WebVTT to do so.
In my video here, I was able to use align:start position:100%
to successfully align captions to the right of the video viewport, but any variation of align-left
or align-end
that I try simply reverts to the default (centre) alignment.
The line-left
syntax from Example 7 in the W3C's WebVTT spec states:
The "line-left" or "line-right" only refers to the physical side of the box to which the "position" setting applies, in a way which is agnostic regarding the horizontal or vertical direction of the cue. It does not affect or relate to the direction or position of the text itself within the box.
But when I try to use this to explicitly specify a left align, I get an error from YouTube when uploading the file (line 17 refers to the 3rd cue - the actual error is the line-left
on line 18):
ANSWER
Answered 2021-Feb-25 at 16:49I've posted this answer purely to document what I used to get the positioning working but I'll be glad to accept an answer from anyone who's better than me at figuring out what the specs say, and in doing so can explain exactly how positioning in WebVTT works.
Since first writing up this question, and after a lot of reading the specs and testing against them, I managed to stumble on the right permutation of code needed to solve this issue, with some caveats.
For the most part:
align:left position:0% size:50%
works to left-align captions
align:right position:100% size:50%
works to right-align them
...at least in my particular case. However, this approach seems to fail completely on longer lines, which fall back to being centre-aligned.
I also don't understand why, but the size
directive needed to be around 50% in my video: setting it to too low or too high a value - including 100%, as would be the case in CSS - also seems to fail.
QUESTION
I have a vtt file as following
...ANSWER
Answered 2021-Feb-02 at 05:43Using re.sub
we can try first removing the unwanted repetitive text. Then, do a second replacement to replace remaining newlines with single spaces:
QUESTION
I need to preprocess transcripts in two different file formats, namely in SRT and WebVTT files. My goal is to remove punctuation marks from the text lines - but not from the timestamps. Because the timestamps in the WebVTT file include full stops instead of commas (as opposed to SRT files), the preprocessing differs in terms of removing the full stops.
The full stops within the timestamps have to remain untouched, whereas those in the text lines shall be removed.
The input file looks like this:
...ANSWER
Answered 2020-Nov-28 at 11:48You can shorten the first 4 replace statements under Remove noisy punctuation from the transcript.
to use a single character class using re.sub.
To keep the dots in the timestamps, you can for example match a dot if no directly followed by a digit.
As all the statements replace the match with an empty string, you can use an alternation |
to combine them.
The update line could look like:
QUESTION
I know how to transform .srt file format to webvtt format in javascript , I want to know how to do the same with .ass & .ssa subtitles files formats to be able to parse them and transform to webvtt format on the fly without using file stream using javascript .
...ANSWER
Answered 2020-Nov-10 at 11:55After a deep search I found what I asked for in an underrated Github repo online named subsrt, can be found here for whoever encounters the same request or similar. it transforms between the following subtitles formats :
MicroDVD SUB (.sub), SubRip (.srt), SubViewer (.sbv), WebVTT (.vtt), SubStation Alpha (.ssa and .ass), SAMI (.smi) aka Synchronized Accessible Media Interchange, LRC (.lrc) aka LyRiCs, JSON (.json)
QUESTION
I'm trying to export my asset as an .mp3
file using AVAssetWriter
.
Here's how I create an instance of it:
...ANSWER
Answered 2020-Nov-09 at 14:24I find it hard to believe that there's no support for exporting an mp3 file
Overcome your difficulty and believe it. Due to a complex of copyright issues, Apple has no license to provide any native capacity to create MP3 files. You might find some third party library that can do it, but you won't do it with AVAssetWriter.
QUESTION
I'm creating subtitles by simply writing a text file and saving it with .srt
extension. And all subtitle files which i have created is working fine. (I just checked it with MxPlayer)
Now I'm building a video player which needs to display the subtitles which I have created.
Initially I tried to load subtitles from web just to prepare the code base. And it worked
...ANSWER
Answered 2020-Jul-25 at 15:58Since, no one answered my question I found answer myself.
first thing is
.vtt
and.srt
are slightly different.
in.vtt
the first line is a textWEBVTT
check this
in.srt
there is no such thingsecondly, very important thing is
MimeTypes
insubtitleFormat
it should beMimeTypes.APPLICATION_SUBRIP
for.srt
andMimeTypes.TEXT_VTT
for.vtt
If you rename
.srt
to.vtt
and added that first lineWEBVTT
manually some parsing exception will come. So, better check webvtt file whether it is proper or not.
That's all now things are working fine.
QUESTION
I use ffmpeg to convert video to hls format (m3u8) and I use videojs to read this video. But I have a problem, subtitles appeared 1.4 seconds before the real timestamp.
I execute this command to extract video, audio and subtitles :
...ANSWER
Answered 2020-Jul-16 at 16:07See my previous answer:
Ffmpeg burnt in subtitles out of sync when converting to hls
For some reason FFMPEG adds about 1.4 seconds to the presentation time of the MPEG-2 Transport Stream when writing. So your video and audio are late. If you add -muxdelay 0 to your FFMPEG command line the sync issue should be resolved.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install webvtt
On a UNIX-like operating system, using your system’s package manager is easiest. However, the packaged Ruby version may not be the newest one. There is also an installer for Windows. Managers help you to switch between multiple Ruby versions on your system. Installers can be used to install a specific or multiple Ruby versions. Please refer ruby-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page