Home
MP4 video encoding for Motorola Xoom
- Details
- Written by Pham Ngoc Hai
If you try to play those 1080p, 720p mkv files directly in your Xoom, you'll find it very jerky and seeking/skipping takes forever. That's because Xoom only supports base line profile of H264, in order to play those files smoothly, you need to reencode them.
I dont want to install handbrake so what I use is:
[code]
ffmpeg -i /path/to/file.mkv -threads 4 -vcodec libx264 -x264opts ref=3:bframes=0:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0:cabac=0:weightp=0 -acodec libfaac -ab 128k -ac 2 -ar 48000 -crf 24 -f mp4 outfile.mp4
[/code]
Motorola Xoom and Adobe Reader
- Details
- Written by Pham Ngoc Hai
I just got my Motorola Xoom Wifi only a few days ago, one of the reasons that I bought it is because I want to read ebooks (pdf, chm...) on it so I spent a huge amount of time getting Adobe Reader on it. Obviously it's not on the Android market since this is a Honeycomb device, so I tried appbrain, now I can see Adobe Reader but Xoom still refuses to install it. I also tried to install a few free pdf readers but none of them actually shows the pdf nicely. When I almost gave up, I saw that Adobe actully put the Adobe Reader for Android on their FTP server, et voila...
ftp://ftp.adobe.com/pub/adobe/reader/android/10.x/10.0.1/
I downloaded the apk file, do a "adb install AdobeReader.apk" the next moment I can see my pdfs are nicely displayed on my Xoom :)
Vinaphone MF 190(ZTE) 3G USB device in linux
- Details
- Written by Pham Ngoc Hai
I was back in Vietnam for the last 3 weeks for my Tet holiday. Back there, my house does not have internet connection, luckily I've got a 3G USB device from my friend, which is MF 190(ZTE). This device comes from Vinaphone - one of the Mobile phone service providers in Vietnam. As usual, this device does not come with linux driver, but after fighting with it for more than half a day, I was able to get it to work on my Archlinux x86_64 laptop. The reason why it took so long was that the signal at the place (my friend's cafe) was too low, I did not know that until I brought it outside.
All that is needed for the 3G USB to works under Archlinux is usb_modeswitch (from community repo) and wvdial (from extra repo). After installing them, when you plug it in, you should see a GSM modem in dmesg. The rests are just wvdial configurarion.
This is my /etc/wvdial.conf
[code]
[Dialer Defaults]
Modem Type = Analog Modem
;ISDN = 1
Modem = /dev/gsmmodem
Phone = *99#
Username = mms
Password = mms
Stupid Mode = 1
Baud = 460800
[Dialer pin]
Init1 = AT+CPIN=1234
[Dialer thenet]
Init3 = ATQ0 V1 E1 +FCLASS=0
Init4 = AT+CGDCONT=1,"IP","m3-card"
[Dialer 3gonly]
Init5 = AT+COPS=0,0,"VinaPhone",2
[Dialer 384k]
Init6 = AT+CGEQMIN=1,4,64,384,64,384
Init7 = AT+CGEQREQ=1,4,64,384,64,384
[/code]
These settings are for Vinaphone 3G network only. Create the file and type:
Remember to replace "1234" in Init1 = AT+CPIN=1234 with your SIM card's PIN.
Then type:
$wvdial pin
$wvdial thenet 3gonly 384k
And that's it, you're already online.
Camel File readLock
- Details
- Written by Pham Ngoc Hai
When running Camel in ServicemMix on linux, the only reliable readLock the we use is "changed", but if the writer is writing very slowly, the defaut time 1s between checks is not sufficient. In the end, we have to implement a org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy to provide to exclusiveReadLockStrategy, This class is basically the same as FileChangedExclusiveReadLockStrategy but with a longer sleep time.
I have made a patch to provide and option for user to specify the time between checks
the patch is at: https://issues.apache.org/jira/browse/CAMEL-3520 but it's only available in camel 2.6.
For older camel versions, we have to provide a exclusiveReadLockStrategy as followed:
[code]
import java.io.File;
import java.io.IOException;
import org.apache.camel.Exchange;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileEndpoint;
import org.apache.camel.component.file.GenericFileOperations;
import org.apache.camel.component.file.strategy.FileChangedExclusiveReadLockStrategy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class ChangedFileExclusiveReadLockStrategy extends FileChangedExclusiveReadLockStrategy {
private static final transient Log LOG = LogFactory.getLog(ChangedFileExclusiveReadLockStrategy.class);
private long timeout;
@Override
public void prepareOnStartup(GenericFileOperations<File> operations, GenericFileEndpoint<File> endpoint) {
// noop
}
public boolean acquireExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, Exchange exchange) throws Exception {
File target = new File(file.getAbsoluteFilePath());
boolean exclusive = false;
if (LOG.isTraceEnabled()) {
LOG.trace("Waiting for exclusive read lock to file: " + file);
}
try {
long lastModified = Long.MIN_VALUE;
long length = Long.MIN_VALUE;
long start = System.currentTimeMillis();
//StopWatch watch = new StopWatch();
while (!exclusive) {
// timeout check
if (timeout > 0) {
long delta = System.currentTimeMillis() - start;
if (delta > timeout) {
LOG.warn("Cannot acquire read lock within " + timeout + " millis. Will skip the file: " + file);
// we could not get the lock within the timeout period, so return false
return false;
}
}
long newLastModified = target.lastModified();
long newLength = target.length();
if (LOG.isTraceEnabled()) {
LOG.trace("Previous last modified: " + lastModified + ", new last modified: " + newLastModified);
LOG.trace("Previous length: " + length + ", new length: " + newLength);
}
if (newLastModified == lastModified && newLength == length) {
// let super handle the last part of acquiring the lock now the file is not
// currently being in progress of being copied as file length and modified
// are stable
exclusive = super.acquireExclusiveReadLock(operations, file, exchange);
} else {
// set new base file change information
lastModified = newLastModified;
length = newLength;
boolean interrupted = sleep();
if (interrupted) {
// we were interrupted while sleeping, we are likely being shutdown so return false
return false;
}
}
}
} catch (IOException e) {
// must handle IOException as some apps on Windows etc. will still somehow hold a lock to a file
// such as AntiVirus or MS Office that has special locks for it's supported files
if (timeout == 0) {
// if not using timeout, then we cant retry, so rethrow
throw e;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Cannot acquire read lock. Will try again.", e);
}
boolean interrupted = sleep();
if (interrupted) {
// we were interrupted while sleeping, we are likely being shutdown so return false
return false;
}
}
return exclusive;
}
private boolean sleep() {
if (LOG.isTraceEnabled()) {
LOG.trace("Exclusive read lock not granted. Sleeping for 10000 millis.");
}
try {
Thread.sleep(10000);
return false;
} catch (InterruptedException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Sleep interrupted while waiting for exclusive read lock, so breaking out");
}
return true;
}
}
public long getTimeout() {
return timeout;
}
public void setTimeout(long timeout) {
this.timeout = timeout;
}
}
[/code]
Linux rapidshare grabber 0.2.2 released
- Details
- Written by Pham Ngoc Hai
Some updates after a long long time since I touched this project.
Now lrg comes with GUI settings that let you choose whether you want it to be shown in system tray - which may not exist in some systems.
The link to download is at:
https://sourceforge.net/projects/lrg/files/lrg-0.2.2/lrg-0.2.2.tar.gz/download
Voila the screen shot:
0.2.2
- Added show/minimize to icon tray options
- Fixed parsing exception
Page 2 of 11