Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Language-agnostic automatic synchronization of subtitles with video, so that subtitles are aligned to the correct starting point within the video.
Turn this: | Into this: |
---|---|
First, make sure ffmpeg is installed. On MacOS, this looks like:
brew install ffmpeg
Next, grab the script. It should work with both Python 2 and Python 3:
pip install git+https://github.com/smacke/subsync@STABLE
subsync video.mp4 -i unsynchronized.srt > synchronized.srt
or
subsync video.mp4 -i unsynchronized.srt -o synchronized.srt
There may be occasions where you have a correctly synchronized srt file in a language you are unfamiliar with, as well as an unsynchronized srt file in your native language. In this case, you can use the correctly synchronized srt file directly as a reference for synchronization, instead of using the video as the reference:
subsync reference.srt -i unsynchronized.srt -o synchronized.srt
subsync
uses the file extension to decide whether to perform voice activity
detection on the audio or to directly extract speech from an srt file.
subsync
usually finishes in 20 to 30 seconds, depending on the length of the
video. The most expensive step is actually extraction of raw audio. If you
already have a correctly synchronized "reference" srt file (in which case audio
extraction can be skipped), subsync
typically runs in less than a second.
The synchronization algorithm operates in 3 steps:
The best-scoring alignment from step 3 determines how to offset the subtitles in time so that they are properly synced with the video. Because the binary strings are fairly long (millions of digits for video longer than an hour), the naive O(n^2) strategy for scoring all alignments is unacceptable. Instead, we use the fact that "scoring all alignments" is a convolution operation and can be implemented with the Fast Fourier Transform (FFT), bringing the complexity down to O(n log n).
In most cases, inconsistencies between video and subtitles occur when starting or ending segments present in video are not present in subtitles, or vice versa. This can occur, for example, when a TV episode recap in the subtitles was pruned from video. Subsync typically works well in these cases, and in my experience this covers >95% of use cases. Handling breaks and splits outside of the beginning and ending segments is left to future work (see below).
To demonstrate how one might use subsync
seamlessly with real video software,
we developed a prototype integration into the popular
VLC media player, which was demoed
during the HackIllinois 2019 project expo. The resulting patch can be found in
the file
subsync-vlc.patch.
Here are instructions for how to use it.
git clone git://git.videolan.org/vlc/vlc-3.0.git
cd vlc-3.0
git checkout 3.0.6
wget https://github.com/smacke/subsync/raw/master/subsync-vlc.patch
git apply subsync-vlc.patch
You should now be able to autosynchronize subtitles using the hotkey Ctrl+Shift+S
(only enabled while subtitles are present).
I am currently working to extend the synchronization algorithm to handle splits / breaks in the middle of video not present in subtitles (or vice versa). It will take some time before I have a robust solution (assuming one is possible). See #10 for more details.
The prototype VLC patch is very experimental -- it was developed under pressure and just barely works. I would love to see this project more robustly integrated with VLC, either directly in the VLC core, or as a plugin. If you or anyone you know has ideas for how to accomplish this, please let me know!
The implementation for this project was started during HackIllinois 2019, for which it received an Honorable Mention (ranked in the top 5 projects, excluding projects that won company-specific prizes).
This project would not be possible without the following libraries:
Code in this project is MIT licensed.
FAQs
Language-agnostic synchronization of subtitles with video via speech detection.
We found that subsume 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.