cr_subtitle_shift
SRT file Time Shift
A few years ago I wrote a hack-ish script in Ruby to shift time in SRT subtitles.
The original script (it's a bit ugly with unnecessary metaprogramming and not clear Time manipulation) is here:
The goal of this new version in Crystal was to:
- assess how easy it would be to port a Ruby script to Crystal (Time's API is different, so this was a bit difficult at first, but not an obstacle)
- assess how fast it could be compared to the Ruby version.
This is the time it takes for the Ruby script to shift a normal movie-length SRT file:
0,13s user 0,02s system 98% cpu 0,158 total
This Crystal version performs like this for the same input file:
0,02s user 0,00s system 106% cpu 0,020 total
It's not a particularly expensive operation, but more than 6x as fast is a very good start.
Installation
You can compile the binary like this:
crystal build src/cr_subtitle_shift.cr --release
Usage
Once compiled you can time shift your SRT files like this:
./cr_subtitle_shift -o add -t 02,100 movie_subtitle.srt movie_subtitle_shifted.srt
Development
You can run the available specs like this:
crystal specs
Contributing
- Fork it ( https://github.com/akitaonrails/cr_subtitle_shift/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- AkitaOnRails - creator, maintainer
Repository
cr_subtitle_shift
Owner
Statistic
- 6
- 0
- 0
- 0
- 0
- over 8 years ago
- May 27, 2016
License
MIT License
Links
Synced at
Thu, 21 Nov 2024 20:07:02 GMT
Languages