Closed captioning is a good thing. It helps not only those who have hearing issues, but also those who speak other languages.
Open captioning, unlike the closed captioning which can be turned off when you don't need it, is burnt to the video and cannot be turned off. It is sometimes annoying when you want to enjoy the pictures but the subtitle keeps distracting you. It is even more annoying when the subtitle is not faithfully typing or translating what the actors are saying, but the imagination or the invention of the subtitler.
We don't want to see those bad open captioning but there is no way to turn them off because they are part of the pictures. But, we can cover it. In those old days, I have to cut a piece of paper and stick it to bottom of the TV screen. Now when I play videos from the computer, I can just run this little Java program NoCaption.class.
NoCaption.class generates a slim black square covering part of the screen. You can drag it to the lower area of the video where the subtitles are usually shown. That would cover the annoying open captioning.
The source code of NoCaption.class is here. You are encouraged to built it yourself with JDK which you can download from Sun's website. If you are too lazy to do that, you can download NoCaption.class here.
To run it, open a terminal, go to where your NoCaption.class locates and run command "java NoCaption". Or you can create a shortcut on the Desktop for the convenience.
To exit the program, double-right-click on the black square.
When the program exits, it writes its location and size to a configuration file nocaption.config. The file does not exist if you haven't run the program before. If you found it, you could open it with WritePad and manually edit the parameters to change the size of the black square. You should do it when the program is not running, because when it exits, it would override what you have changed. If you have messed up with the configuration file, don't worry, just delete the file. The program will use the default configuration and generate the file again.
Monday, October 18, 2010
Java source code of NoCaption
import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import java.util.Properties;
public class NoCaption {
public static void main(String[] args) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// no title bar
frame.setUndecorated(true);
frame.setAlwaysOnTop( true );
frame.getContentPane().setBackground(Color.BLACK);
// set size and location
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize();
int scrnH = (int)scrnsize.getHeight();
int scrnW = (int)scrnsize.getWidth();
try {
Properties prop = new Properties();
InputStream is = new FileInputStream(fileName);
prop.load(is);
locX = Integer.parseInt(prop.getProperty("locationX"));
locY = Integer.parseInt(prop.getProperty("locationY"));
frmW = Integer.parseInt(prop.getProperty("frameWidth"));
frmH = Integer.parseInt(prop.getProperty("frameHeight"));
is.close();
} catch (Exception x) {
locX = scrnW/6;
locY = scrnH-scrnH/3;
frmW = scrnW*2/3;
frmH = scrnH/8;
}
frame.setLocation(locX, locY);
frame.setSize(frmW, frmH);
// mouse handler
frame.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
origin.x = e.getX();
origin.y = e.getY();
}
public void mouseClicked(MouseEvent e) {
// double right click to exit
if (e.getClickCount() >= 2 && MouseEvent.BUTTON3 == e.getButton()) {
// Save config.
try {
Properties prop = new Properties();
Point pnt = frame.getLocation();
prop.setProperty("locationX", String.valueOf((int)pnt.getX()));
prop.setProperty("locationY", String.valueOf((int)pnt.getY()));
prop.setProperty("frameWidth", String.valueOf(frmW));
prop.setProperty("frameHeight", String.valueOf(frmH));
OutputStream os = new FileOutputStream(fileName);
prop.store(os, "");
os.close();
} catch (Exception x) {}
System.exit(0);
}
}
});
frame.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
Point p = frame.getLocation();
frame.setLocation(p.x + e.getX() - origin.x,
p.y + e.getY() - origin.y);
}
});
frame.setVisible( true );
}
static private Point origin = new Point();
static private JFrame frame = new JFrame();
static private String fileName = "nocaption.config";
static private int locX;
static private int locY;
static private int frmW;
static private int frmH;
}
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import java.util.Properties;
public class NoCaption {
public static void main(String[] args) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// no title bar
frame.setUndecorated(true);
frame.setAlwaysOnTop( true );
frame.getContentPane().setBackground(Color.BLACK);
// set size and location
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize();
int scrnH = (int)scrnsize.getHeight();
int scrnW = (int)scrnsize.getWidth();
try {
Properties prop = new Properties();
InputStream is = new FileInputStream(fileName);
prop.load(is);
locX = Integer.parseInt(prop.getProperty("locationX"));
locY = Integer.parseInt(prop.getProperty("locationY"));
frmW = Integer.parseInt(prop.getProperty("frameWidth"));
frmH = Integer.parseInt(prop.getProperty("frameHeight"));
is.close();
} catch (Exception x) {
locX = scrnW/6;
locY = scrnH-scrnH/3;
frmW = scrnW*2/3;
frmH = scrnH/8;
}
frame.setLocation(locX, locY);
frame.setSize(frmW, frmH);
// mouse handler
frame.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
origin.x = e.getX();
origin.y = e.getY();
}
public void mouseClicked(MouseEvent e) {
// double right click to exit
if (e.getClickCount() >= 2 && MouseEvent.BUTTON3 == e.getButton()) {
// Save config.
try {
Properties prop = new Properties();
Point pnt = frame.getLocation();
prop.setProperty("locationX", String.valueOf((int)pnt.getX()));
prop.setProperty("locationY", String.valueOf((int)pnt.getY()));
prop.setProperty("frameWidth", String.valueOf(frmW));
prop.setProperty("frameHeight", String.valueOf(frmH));
OutputStream os = new FileOutputStream(fileName);
prop.store(os, "");
os.close();
} catch (Exception x) {}
System.exit(0);
}
}
});
frame.addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
Point p = frame.getLocation();
frame.setLocation(p.x + e.getX() - origin.x,
p.y + e.getY() - origin.y);
}
});
frame.setVisible( true );
}
static private Point origin = new Point();
static private JFrame frame = new JFrame();
static private String fileName = "nocaption.config";
static private int locX;
static private int locY;
static private int frmW;
static private int frmH;
}
Friday, October 8, 2010
Firefox Extension: Wiktionary and Google Translate
Former Google Dictionary and Google Translate
(As you have known, Google Dictionary site has been shut down. We try to switch to Wiktionary.org for the dictionary functionality of this extension. Since version 3.0, it is renamed to Wiktionary and Google Translate. You can install the latest version from https://addons.mozilla.org/en-US/firefox/addon/google-dictionary-and-google-t/versions/ and help test it. English version of Wiktionary.org is well formatted, the other language versions are not. As a result, other languages may not be supported yet.)
(Many of you are frustrated when you find the extension stops working. We can totally understand that. Before reporting the problem, please try the latest version in the above link first. If the latest version is not working for you, please tell us what language you are using. As we stated above, many languages need special handling because they are formatted differently in Wiktionary.)
The extension brings two functionalities to your Firefox browser:
In-line Dictionary
Double-click or highlight a word, and a little pop-up will show the definition of it in your language.
Alternatively, you can move your mouse over the word that you want to translate while pressing down the Ctrl key.
At the top-right corner of the little pop-up, there is a "more" link which will lead you to the full definition at Google Dictionary web site. (If the language or the translation is not supported by Google Dictionary, the "more" link will lead you to Google Translate web site instead.)
To close the little pop-up, just click on any blank place on the browser, or press the Esc button. The little pop-up must be closed before you can activate another in-line translation. After version 2.2, you have the option to close the pop-up by moving the mouse, but you need to enable it first (see the Options section below).
Two other ways of in-line dictionary lookup is added in version 2.1.
In version 2.1, a Google Dictionary button (see the left side) is added into the toolbar
palette. You can drag it into your toolbar. To use it, select/highlight the word, phrase or sentence you want to look up and click on the Google Dictionary button. See this and this posts for how to add a button from the palette into your toolbar.
In version 2.1, you can select/highlight the word, phrase or sentence you want to look up and right click on it to see a new item Google Dictionary in the context menu. Click on it to look up what you select/highlight.
Page Translation
In version 1.7, a Google Translate button is added into the toolbar palette. You can drag it into your toolbar to enable 1-click whole page translation into your own language. See this and this posts for how to add a button from the palette into your toolbar.
Alternatively, you can click on the Tools menu from the menu bar, and select Translate Page.
Options
Open the Options dialog to setup the extension.
In version 2.0, a new tab Style is added to the Options dialog. The user can apply his/her own style to the Google Dictionary pop-up.
Download
Download the extension from the official Mozilla Add-ons web site: https://addons.mozilla.org/en-US/firefox/addon/239624/
Q&A
What is aggressive mode?
In aggressive mode, the extension keeps on capturing the words your mouse hovering over at any time. The words are captured but they are not sent out to Google until you press the Ctrl key. Whenever you press the Ctrl key, the word under the mouse will get translated. It adds some overhead but usually does not matter because your browser is idle while you are reading the page.
However, if you do not like the idea of keeping the browser active, you can uncheck it. Then the mouse only captures words when you are pressing down the Ctrl key.
Why isn't my language on the list?
A language must be supported by Google Translate in order to be added to our list.
We haven't tested our extension with all the languages yet. If your language is supported by Google Translate, it will be added soon.
Why does the "more" link take me to Google Dictionary sometimes but Google Translate at other times?
lookup from language XX to your language, the "more" link will take you to Google Translate.
Why is the "more" link disabled sometimes?
As answered in the previous question, the "more" link could sometimes take you to Google Translate. The problem is that the URL translate.google.com does not supported encryption (https). If you are visiting an encrypted web page, we do not want to send anything on your encrypted page to a plain/unencrypted URL. Therefore, we disable the link to Google Translate web site.
Why does the inline popup show only "??" ?
It means Google Translate has problems when doing the translation. The most possible reason is that Google Translate does not support a translation from language XX to your language. The other common reason is that sometimes Google Translate responds too slowly and our request gets timeout.
Why doesn't the inline popup show the meaning of the word, but only repeat the original word?
The inline popup shows whatever Google Translate and Google Dictionary return. The most common reason is that Google Translate does not find the meaning of that word in their database, so it returns the original word as the result. I also found that sometime Google Translate wrongly detect the language of that word, so it cannot translate it.
Whole page translation is blocked by Flashblock extension.
That is because Flashblock extension blocks some Google online services. You need to add google.com or the regional Google URL to the white list of Flashblock. There is nothing our extension can do because it is outside of its scope. See the reason and detail in this post.
Why isn't Firefox 3.5 supported?
In some versions of Firefoxsurport Firefox 3.5 soon, I do not plan to add extra fix for it.
When realizing the above requirement, you can make a little change yourself to get it installed. Just change the value of "em:minVersion" from 3.6 to 3.5 in the file install.rdf.
New features.
Any suggestions and requests are welcome. If the feature you request does not show up in the new release, please be patient. I will add new features according to their priorities. In the meantime, bug-fixes are my number one priority.
(As you have known, Google Dictionary site has been shut down. We try to switch to Wiktionary.org for the dictionary functionality of this extension. Since version 3.0, it is renamed to Wiktionary and Google Translate. You can install the latest version from https://addons.mozilla.org/en-US/firefox/addon/google-dictionary-and-google-t/versions/ and help test it. English version of Wiktionary.org is well formatted, the other language versions are not. As a result, other languages may not be supported yet.)
(Many of you are frustrated when you find the extension stops working. We can totally understand that. Before reporting the problem, please try the latest version in the above link first. If the latest version is not working for you, please tell us what language you are using. As we stated above, many languages need special handling because they are formatted differently in Wiktionary.)
The extension brings two functionalities to your Firefox browser:
- in-line translation/dictionary look-up of words;
- translation of the whole page.
In-line Dictionary
Double-click or highlight a word, and a little pop-up will show the definition of it in your language.
Alternatively, you can move your mouse over the word that you want to translate while pressing down the Ctrl key.
At the top-right corner of the little pop-up, there is a "more" link which will lead you to the full definition at Google Dictionary web site. (If the language or the translation is not supported by Google Dictionary, the "more" link will lead you to Google Translate web site instead.)
To close the little pop-up, just click on any blank place on the browser, or press the Esc button. The little pop-up must be closed before you can activate another in-line translation. After version 2.2, you have the option to close the pop-up by moving the mouse, but you need to enable it first (see the Options section below).
Two other ways of in-line dictionary lookup is added in version 2.1.
In version 2.1, a Google Dictionary button (see the left side) is added into the toolbar
palette. You can drag it into your toolbar. To use it, select/highlight the word, phrase or sentence you want to look up and click on the Google Dictionary button. See this and this posts for how to add a button from the palette into your toolbar.In version 2.1, you can select/highlight the word, phrase or sentence you want to look up and right click on it to see a new item Google Dictionary in the context menu. Click on it to look up what you select/highlight.
Page Translation
In version 1.7, a Google Translate button is added into the toolbar palette. You can drag it into your toolbar to enable 1-click whole page translation into your own language. See this and this posts for how to add a button from the palette into your toolbar.
Alternatively, you can click on the Tools menu from the menu bar, and select Translate Page.
Options
Open the Options dialog to setup the extension.
- Select your language
If your language is not in the list, read the section "Why isn't my language on the list".
- Enable select-to-translate
If it is checked, you can double-click any word or highlight a phrase to see the in-line translation.
- Enable double-click-to-translate (since version 1.5)
If it is checked, you can double-click any word to see the in-line translation. With this new option, you can uncheck the above Enable select-to-translate option which may cause inconvenience when you want to copy & paste some text from the web page.
- Enable Ctrl-hover-to-translate
If it is checked, you can press down the Ctrl key and move your mouse over the word to view the in-line translation of it.
Since version 2.3, you can choose to use Ctrl+Shift or Ctrl+Alt with hover-over to popup the in-line dictionary.
Since version 2.3, you can choose to use Ctrl+Shift or Ctrl+Alt with hover-over to popup the in-line dictionary.
- Aggressive mode
If it is not checked, you must press down the Ctrl key first and keep it down when you move the mouse to translate a word. If you want to know the technical detail, read the section "What is aggressive mode".
- Disable language auto-detection. I only look up words in ... (since version 1.6)
This option is for the inline dictionary. If it is checked, the language auto-detection function is disabled. Therefore, you need to choose which language the original words that you look up are in. Google's language auto-detection is convenient, but not perfect. Many complaints have been received saying that the languages were wrongly detected. Even Google is sometimes not so confident about its language detection result. So this option is added to give a better experience to those who only read articles in one specific language.
- Move mouse away to close the popup (since version 2.2)
This option is for the inline dictionary. If it is checked, you can close the popup by moving the mouse away so that you do not need to click somewhere like before. This option is disable by default so the existing users do not get surprised after the upgrade.
In version 2.0, a new tab Style is added to the Options dialog. The user can apply his/her own style to the Google Dictionary pop-up.
- Enable my style
If it is checked, the CSS code in the following input box will be applied to the extension to let user override the default style. There are some samples of the CSS code can be found here. They can be simply copied and pasted into the input box.
Download
Download the extension from the official Mozilla Add-ons web site: https://addons.mozilla.org/en-US/firefox/addon/239624/
Q&A
What is aggressive mode?
In aggressive mode, the extension keeps on capturing the words your mouse hovering over at any time. The words are captured but they are not sent out to Google until you press the Ctrl key. Whenever you press the Ctrl key, the word under the mouse will get translated. It adds some overhead but usually does not matter because your browser is idle while you are reading the page.
However, if you do not like the idea of keeping the browser active, you can uncheck it. Then the mouse only captures words when you are pressing down the Ctrl key.
Why isn't my language on the list?
A language must be supported by Google Translate in order to be added to our list.
We haven't tested our extension with all the languages yet. If your language is supported by Google Translate, it will be added soon.
Why does the "more" link take me to Google Dictionary sometimes but Google Translate at other times?
lookup from language XX to your language, the "more" link will take you to Google Translate.
Why is the "more" link disabled sometimes?
As answered in the previous question, the "more" link could sometimes take you to Google Translate. The problem is that the URL translate.google.com does not supported encryption (https). If you are visiting an encrypted web page, we do not want to send anything on your encrypted page to a plain/unencrypted URL. Therefore, we disable the link to Google Translate web site.
Why does the inline popup show only "??" ?
It means Google Translate has problems when doing the translation. The most possible reason is that Google Translate does not support a translation from language XX to your language. The other common reason is that sometimes Google Translate responds too slowly and our request gets timeout.
Why doesn't the inline popup show the meaning of the word, but only repeat the original word?
The inline popup shows whatever Google Translate and Google Dictionary return. The most common reason is that Google Translate does not find the meaning of that word in their database, so it returns the original word as the result. I also found that sometime Google Translate wrongly detect the language of that word, so it cannot translate it.
Whole page translation is blocked by Flashblock extension.
That is because Flashblock extension blocks some Google online services. You need to add google.com or the regional Google URL to the white list of Flashblock. There is nothing our extension can do because it is outside of its scope. See the reason and detail in this post.
Why isn't Firefox 3.5 supported?
In some versions of Firefoxsurport Firefox 3.5 soon, I do not plan to add extra fix for it.
When realizing the above requirement, you can make a little change yourself to get it installed. Just change the value of "em:minVersion" from 3.6 to 3.5 in the file install.rdf.
New features.
Any suggestions and requests are welcome. If the feature you request does not show up in the new release, please be patient. I will add new features according to their priorities. In the meantime, bug-fixes are my number one priority.
Subscribe to:
Posts (Atom)

