It's a simple script created to make a .srt file starting from a VIA (VGG Image Annotator) .json file obtained by annotating a video.
Annotations on the interface of VIA aren't comfortably viewable, especially for many different labels. However, using a .srt file, you can see annotations as subtitles on a video player to control them more comfortably.
VGG Image Annotator is a simple and standalone manual annotation software for image, audio and video. VIA runs in a web browser and does not require any installation or setup. The complete VIA software fits in a single self-contained HTML page of size less than 400 Kilobyte that runs as an offline application in most modern web browsers.
Source: VGG Image Annotator
VIA projects are saved by using .json files. In the .json file, all the intervals and the name of the corresponding label are stored, even the name of the video that has been annotated.
The .srt file is created following the standard format, specifically:
- The index starts by 0
- The beginning timestamp and the ending timestamp of the interval, each in hh:mm:ss,ms
- The label
- A blank line
In the .json file also the regions are stored but, they are ignored during the conversion process.
N.B. If you haven't already installed the following packages, you need to do it.
-
pandas
-
numpy
-
Clone the repository
-
$ cd path_to_cloned_repo
It's possible to use this command to see the arguments that can be used.
$ python via_json_to_srt.py --help
This is the help message:
-h, --help show this help message and exit
-f FILE, --file FILE path to a .json file
-fo FOLDER, --folder FOLDER path to a folder. It'll load only .json files
-o OUTPUT, --output OUTPUT output folder for .srt file(s). If not specified, the .srt file(s) will be saved
on the same location of .json file(s)
Using the folder argument, the script will convert all the json files that are in the VIA's format in the directory and subdirectories.
If -f and -fo arguments are used at the same time, the script will ignore the -fo argument.