Skip to content
Snippets Groups Projects
Commit 57243c40 authored by Gael's avatar Gael
Browse files

v1.0.0 release

parents
No related branches found
No related tags found
No related merge requests found
README.md 0 → 100644
[//]: # "#to make links in gitlab: example with racon https://github.com/isovic/racon"
[//]: # "tricks in markdown: https://openclassrooms.com/fr/courses/1304236-redigez-en-markdown"
| usage | R dependencies |
| --- | --- |
| [![R Version](https://img.shields.io/badge/code-R-blue?style=plastic)](https://cran.r-project.org/mirrors.html) | [![Dependencies: R Version](https://img.shields.io/badge/R-v4.0.2-blue?style=plastic)](https://cran.r-project.org/mirrors.html) |
| [![License: GPL-3.0](https://img.shields.io/badge/licence-GPL%20(%3E%3D3)-green?style=plastic)](https://www.gnu.org/licenses) | [![Dependencies: R Package](https://img.shields.io/badge/package-car%20v3.0.9-blue?style=plastic)](https://cran.r-project.org/web/packages/car/index.html) |
## TABLE OF CONTENTS
- [AIM](#aim)
- [CONTENT](#content)
- [HOW TO RUN](#how-to-run)
- [OUTPUT](#output)
- [VERSIONS](#versions)
- [LICENCE](#licence)
- [CITATION](#citation)
- [CREDITS](#credits)
- [WHAT'S NEW IN](#what's-new-in)
## AIM
Shift the time of .srt subtitle files
## CONTENT
**sub_shift.R** file that can be executed using a CLI (command line interface) or sourced in R or RStudio.
**dataset** folder containing some datasets than can be used as examples (from https://en.wikipedia.org/wiki/SubRip)
**example_of_result** folder containing an example of result obtained with the Internatilzation dataset
## HOW TO RUN
### Using a R GUI (graphic user interface, i.e., R or RStudio windows)
1) Open the sub_shift.R file and set the parameters (2 first lines)
2) Open R or RStudio
3) Source the anova_contrasts.R file, for instance using the following instruction:
` source("C:/Users/Gael/Desktop/sub_shift.R") `
### Using a R CLI (command line interface)
1) Open the sub_shift.R file and set the parameters (2 first lines)
2) Open a shell windows
3) run sub_shift.R, for instance using the following instruction:
` Rscript sub_shift.R `
For cygwin, use something like:
` /cygdrive/c/Program\ Files/R/R-4.0.2/bin/Rscript sub_shift.R `
## OUTPUT
The same file in the same directory but with time shifted
## VERSIONS
The different releases are tagged [here](https://gitlab.pasteur.fr/gmillot/sub_shift/-/tags)
## LICENCE
This package of scripts can be redistributed and/or modified under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchandability or fitness for a particular purpose.
See the GNU General Public License for more details at https://www.gnu.org/licenses.
## CITATION
Not yet published
## CREDITS
[Gael A. Millot](https://gitlab.pasteur.fr/gmillot), Hub-CBD, Institut Pasteur, USR 3756 IP CNRS, Paris, France
## WHAT'S NEW IN
### v1.0.0
Everything
1
00:02:16,612 --> 00:02:19,376
Senator, we're making
our final approach into Coruscant.
2
00:02:19,482 --> 00:02:21,609
Very good, Lieutenant.
3
00:03:13,336 --> 00:03:15,167
We made it.
4
00:03:18,608 --> 00:03:20,371
I guess I was wrong.
5
00:03:20,476 --> 00:03:22,671
There was no danger at all.
\ No newline at end of file
1
00:02:15,612 --> 00:02:18,376
Senator, we're making
our final approach into Coruscant.
2
00:02:18,482 --> 00:02:20,609
Very good, Lieutenant.
3
00:03:12,336 --> 00:03:14,167
We made it.
4
00:03:17,608 --> 00:03:19,371
I guess I was wrong.
5
00:03:19,476 --> 00:03:21,671
There was no danger at all.
shift <- -1 # in seconds
in.path <- "C:/Users/Gael/Documents/Git_projects/subtitle_time_shift/dataset/movie.srt" # absolute path of the input file
a <- read.table(in.path, sep = "\t", check.names = FALSE, quote = "", comment.char = "", blank.lines.skip = FALSE)
out.path <- paste0(sub(x = in.path, pattern = "\\.srt$", replacement = ""), "_shift.srt")
tempo.log <- grepl(x = a[, 1], pattern = "-->")
b <- a[tempo.log, ]
d <- strsplit(x = b, split = " --> ") # "01:00:15,602"
e <- lapply(X = d, FUN = function(x = X){
x <- lubridate::period_to_seconds(lubridate::hms(x) + lubridate::seconds(shift)) # hms(x) convert into hms object and lubridate::hms(x) + lubridate::seconds(shift) shifts the time and lubridate::period_to_seconds() convert to seconds
x <- as.character(hms::as_hms(x)) # "01:00:17.102"
sub(x = x, pattern = "\\.", replacement = ",")
})
f <- a
f[tempo.log, ] <- sapply(X = e, FUN = function(x = X){paste0(x, collapse = " --> ")})
write.table(f, file = out.path, row.names = FALSE, col.names = FALSE, append = FALSE, quote = FALSE, sep = "\t")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment