Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Lossless Cut | 16,775 | 9 days ago | 189 | gpl-2.0 | JavaScript | |||||
The swiss army knife of lossless video/audio editing | ||||||||||
Ffsubsync | 5,993 | 1 | a month ago | 24 | January 08, 2022 | 50 | mit | Python | ||
Automagically synchronize subtitles with video. | ||||||||||
Gifify | 5,420 | 10 | 6 | 4 years ago | 16 | March 06, 2019 | 29 | isc | JavaScript | |
😻 Convert any video file to an optimized animated GIF. | ||||||||||
Editly | 4,050 | a month ago | 23 | August 28, 2022 | 106 | mit | JavaScript | |||
Slick, declarative command line video editing & API | ||||||||||
Tdarr | 2,096 | a month ago | 41 | gpl-3.0 | Makefile | |||||
Tdarr - Distributed transcode automation using FFmpeg/HandBrake + Audio/Video library analytics + video health checking (Windows, macOS, Linux & Docker) | ||||||||||
Ffmediaelement | 901 | 5 | a year ago | 25 | June 05, 2021 | 35 | other | C# | ||
FFME: The Advanced WPF MediaElement (based on FFmpeg) | ||||||||||
Yt Whisper | 857 | 4 months ago | 17 | mit | Python | |||||
Using OpenAI's Whisper to automatically generate YouTube subtitles | ||||||||||
Videoshow | 742 | 16 | 10 | 7 months ago | 14 | February 10, 2020 | 48 | mit | JavaScript | |
Simple node.js utility to create video slideshows from images with optional audio and visual effects using ffmpeg | ||||||||||
Crunchyroll Downloader V3.0 | 607 | a month ago | 5 | Visual Basic .NET | ||||||
Downloader for Crunchyroll | ||||||||||
H265ize | 522 | 1 | 5 months ago | 8 | August 07, 2016 | 64 | mit | JavaScript | ||
A node utility utilizing ffmpeg to encode videos with the hevc codec. |
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: |
---|---|
![]() |
![]() |
Please consider supporting Ukraine rather than donating directly to this project. That said, at the request of some, you can now help cover my coffee expenses using the Github Sponsors button at the top, or using the below Paypal Donate button:
First, make sure ffmpeg is installed. On MacOS, this looks like:
brew install ffmpeg
(Windows users: make sure ffmpeg
is on your path and can be referenced
from the command line!)
Next, grab the package (compatible with Python >= 3.6):
pip install ffsubsync
If you want to live dangerously, you can grab the latest version as follows:
pip install git+https://github.com/smacke/[email protected]
ffs
, subsync
and ffsubsync
all work as entrypoints:
ffs 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:
ffsubsync reference.srt -i unsynchronized.srt -o synchronized.srt
ffsubsync
uses the file extension to decide whether to perform voice activity
detection on the audio or to directly extract speech from an srt file.
If the sync fails, the following recourses are available:
--no-fix-framerate
;--gss
to use golden-section search
to find the optimal ratio between video and subtitle framerates (by default,
only a few common ratios are evaluated);--max-offset-seconds
greater than the default of 60, in the
event that the subtitles are out of sync by more than 60 seconds (empirically
unlikely in practice, but possible).--vad=auditok
since auditok can
sometimes work better in the case of low-quality audio than WebRTC's VAD.
Auditok does not specifically detect voice, but instead detects all audio;
this property can yield suboptimal syncing behavior when a proper VAD can
work well, but can be effective in some cases.If the sync still fails, consider trying one of the following similar tools:
ffsubsync
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), ffsubsync
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. FFsubsync 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).
Besides general stability and usability improvements, one line of work aims to extend the synchronization algorithm to handle splits / breaks in the middle of video not present in subtitles (or vice versa). Developing a robust solution will take some time (assuming one is possible). See #10 for more details.
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.