My work for this week focused on integrating the new features that I developed throughout GSOC into the GUI, and also adding support for multiple OCR languages to DVB subtitles.
The most common users of CCExtractor use the GUI, and may not necessarily be experienced with the command line. Hence, it was important to integrate the new features into the GUI so that they may be available to a much wider audience.
The GUI is essentially a program which provides a graphical interface to the user who can supply the required options with ease, and the program in turn calls the ccextractor executable after parsing the options that the user supplied and converting them into a command string. The GUI interacts with the executable and works just like the normal executable would from the command line, but it gives easy to interpret visual feedback to the user, bundled in an easy to use application.
In addition to the SourceForge Windows GUI, CCExtractor also has a cross-platform Qt GUI which was developed by Oleg Kisselef in GSOC 2015 (https://github.com/kisselef/ccextractor-gui-qt). I needed to add parsing support for the options which I had added to the main program and create an interface which would allow those options to be sent to the executable.
It was fairly easy to add the options to the ‘Options’ window. A main checkbox needs to be checked in order to access the other parameters (equivalent to how -hardsubx needs to be specified before any related options on the command line). After I had created the UI, I had to map the elements in the GUI (radio buttons, sliders, checkboxes) to events in the application which would pass on the appropriate commands to the executable. I also verified that the options worked as intended, and constrained them to take only valid values, and also be initialized to the default and recommended values.
The resultant additions to the Qt GUI on Linux look like this:-
Another thing which I did this week was to add support for potentially 99 different languages using Tesseract’s .traineddata files. Before this point, only English was supported.
Adding this feature was like solving a partially solved jigsaw puzzle. I just had to complete some of the existing code to search for Tesseract language packs and make sure that it looked for the necessary files in the correct locations.
Initially, I had also added special cases for certain languages like Chinese (simplified) which seemed to come with non standard language codes in the video stream. However, instead of hard-coding a particular case like this, it was deemed better to let the user specify the non standard names, if at all necessary.
I added the
-dvblang allows the user to select which language’s caption stream will be processed. In the event that there were multiple caption streams in the video, only the one specified by the parameter would be processed.
-ocrlang allows the user to manually select the name of the Tesseract .traineddata file. This option is helpful if you want to OCR a caption stream of one language with the data of another language. e.g.
-dvblang chs -ocrlang chi_tra will decode the Chinese (simplified) caption stream but perform OCR using the Chinese (Traditional) trained data. This option is also useful when the Tesseract .traineddata files don’t come with standard ISO names.