Categories

G2Android 1.5.0 is available : major release !

Finally !
During a long period of calm, I finally released a new version (with new features) of the Android client for remote galleries Gallery2 (your photos on your website), G2Android.
If you have a look at the G2Android project homepage, you will see that the following issues (bug and enhancements) have been closed :
Version 1.5.0, 19th of July 2010 Major release

  • issue #33 Enable uploaded photo title modification
  • issue #41 Malformed Gallery 2 URL leads to G2Android forced close
  • issue #37 Uploaded photo looses .jpg file extension
  • issue #42 Feature Suggestion: Provide automatic login when started
  • issue #20 Share via camera app?
  • issue #15 Enhancement: Add multiple photo uploading

The major new feature is clearly the « add photo to gallery » feature : I created a new Activity, UploadPhoto , which can be called from 2 external intents :

AndroidManifest.xml

 <activity android:name=".activity.UploadPhoto" android:label="@string/upload_photo_title" >
                        <intent -filter>
                                        <action android:name="android.intent.action.SEND" />
                                        <action android:name="android.intent.action.SEND_MULTIPLE" />
                                        <category android:name="android.intent.category.DEFAULT" />
                                        <data android:mimeType="image/*" />
                        </intent>
 </activity>

So now the user can send a new photo or a batch of photos from another application, the android gallery app for example; the big work was then to decode the URIs of the photos to find the photo file on the phone, and then send it to the gallery; also I had to make sure that the user is still connected to the gallery, if not, he must login again.

Also, the user is now able to take a picture and send it to his gallery, without leaving g2android; this has been done adding the camera permission in the AndroidManifest.xml :

<uses -permission android:name="android.permission.CAMERA"></uses>

This is the easy part ;-)
Then, when your app receive a photo from the Camera, it does not receive an URI pointing to a photo file; nope, you get a Bitmap object you have transform into a file, to be able to send it to the remote gallery :

UploadPhoto

                                                Bundle extras = intent.getExtras();
                                                Bitmap bm = null;
                                                Object o = extras.get("data");
                                                if (o != null && o instanceof Bitmap) {
                                                        bm = (Bitmap) o;
                                                        try {
                                                                StringBuilder stringBuilder = new StringBuilder();
                                                                stringBuilder.append(Settings
                                                                                .getG2AndroidPath(this));
                                                                stringBuilder.append("/");
                                                                StringBuilder stringBuilderFileName = new StringBuilder();
                                                                stringBuilderFileName.append(fileName);
                                                                stringBuilderFileName
                                                                                .append(System.currentTimeMillis());
                                                                stringBuilderFileName.append(".jpg");
                                                                stringBuilder.append(stringBuilderFileName);
                                                                imageFromCamera = new File(
                                                                                stringBuilder.toString());
                                                                FileOutputStream fos = new FileOutputStream(
                                                                                imageFromCamera);
                                                                bm.compress(CompressFormat.JPEG, 100, fos);
                                                                fos.flush();
                                                                fos.close();
 
                                                                mImageUri=Uri.fromFile(imageFromCamera);
                                                                fileName = stringBuilderFileName.toString();
 
                                                        } catch (FileNotFoundException e) {
                                                                ShowUtils.getInstance().alertFileProblem(e.getMessage(),this);
                                                        } catch (IOException e) {
                                                                ShowUtils.getInstance().alertFileProblem(e.getMessage(),this);
                                                        }
 
                                                }

I also optimized the application, issue #37 (Uploaded photo looses .jpg file extension) was in fact due to the fact that I re created the photo file before sending it; instead of using a projection of the URI to get its path on the phone :

UriUtils

public static String getFileNameFromUri(Uri uri, Activity activity) {
                String[] projection = { MediaStore.Images.ImageColumns.DISPLAY_NAME };
                String fileName=null;
                Cursor c = activity.managedQuery(uri, projection, null, null, null);
                if (c != null && c.moveToFirst()) {
                        fileName = c.getString(0);
                }
                return fileName;
}

Also shipping with this new version, Chinese i18n thanks to the chinese android market, GoAPK and also new art from Dan, who just posted a comment to the blog proposing to add new art; thanks again to you both ! You make the application richer !

So now, what remains to be done ? well, the compatibility with Gallery3, as the G3 remote API is almost stable now, thanks to the work of Bharat, Tim, and many others; a java implementation is already under work, I will check if I can use it instead of… re inventing the wheel !
More details to come, for sure !

You can download G2Android from the Android Market, SlideMe, Applibs, etc.. and also from the G2Android project homepage
.
Enjoy this app as much as I enjoy working on it, and if you like it, don’t forget to flattr me ;-) !

Encoder vos videos en Webm (vp8) avec ffmpeg sous Ubuntu

Depuis la libération du codec VP8 (et de son conteneur WebM) de ON2 technologies par Google en Mai 2010, la communauté open source (et les amateurs de video !) a trouvé le digne remplaçant de theora, finalement peu performant, et surtout un adversaire de poids face au codec video breveté et certainement pas standard h264.
Cet article a pour but d’expliquer comment :

  • installer ffmpeg avec le support de webm sur Ubuntu
  • encoder une vidéo au format webm
  • lire une vidéo au format webm

Installer ffmpeg avec le support de webm sur Ubuntu

Pour cela, je vais reprendre en quasi intégralité cet excellent article de Steph sur l’installation de ffmpeg avec support de Webm sur Ubuntu 10.04 (lucid Lynx).
On enlève les versions originales de ffmpeg et eventuellement de x264 :

sudo apt-get remove ffmpeg x264 libx264-dev

On met à jour le système de paquets et on installe les librairies nécessaires sur le système :

sudo apt-get update
sudo apt-get install build-essential subversion git-core checkinstall yasm texi2html libfaac-dev libfaad-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev

Récupération des sources, compilation et installation de x264 (optionnel, si vous voulez aussi encoder en x264) sous forme de paquets pour votre système (checkinstall wrappe « make install » en installant en plus le binaire obtenu sous forme de paquets debian dans votre système)

cd
git clone git://git.videolan.org/x264.git
cd x264
./configure
make
sudo checkinstall --pkgname=x264 --pkgversion "2:0.`grep X264_BUILD x264.h -m1 | cut -d' ' -f3`.`git rev-list HEAD | wc -l`+git`git rev-list HEAD -n 1 | head -c 7`" --backup=no --default

Récupération des sources, compilation et installation de VP8, librairie nommée libvpx sous forme de paquets pour votre système (checkinstall wrappe « make install » en installant en plus le binaire obtenu sous forme de paquets debian dans votre système)

cd
git clone git://review.webmproject.org/libvpx.git
cd libvpx
./configure
make
sudo checkinstall --pkgname=libvpx --pkgversion="`date +%Y%m%d%k%M`-git" --backup=no --nodoc --default

Récupération des sources, compilation et installation de ffmpeg (enfin!)sous forme de paquets pour votre système (checkinstall wrappe « make install » en installant en plus le binaire obtenu sous forme de paquets debian dans votre système, à noter que pour ffmpeg vous aurez une erreur lors du checkinstall, qui n’empêchera pas l’installation d’aboutir)
Si vous avez installé x264, vous pouvez ajouter comme ci dessous ajouter le support x264 à ffmpeg : –enable-libx264 ; à noter que l’option –enable-libvpx vous donnera accès à l’encodage webm

cd
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
make
sudo checkinstall --pkgname=ffmpeg --pkgversion "4:SVN-r`svn info | grep Revision | awk '{ print $NF }'`" --backup=no --default
hash x264 ffmpeg ffplay

Alors il est vrai que c’est toujours plus simple d’installer des paquets avec apt-get install que de compiler des sources, mais le support de webm dans ffmpeg est à ce jour tellement récent que vous ne trouverez pas de paquets pour votre distribution !

Encoder vos vidéos en webm avec ffmpeg

Rien de plus simple !

ffmpeg -i input.avi -threads 2 output.webm

(sauf qu’il semnlearait que le -threads 2, supposé donner 2 threads à ffmpeg, utile pour les dual core, ne soit pas supporté, à ce jour, pour webm)

Lire vos vidéos encodées en webm

Avec ffplay

Vous avez déjà installé précédemment ffmplay :

ffplay output.webm

Avec vlc

Vous pouvez aussi les lire avec la dernière version de VLC, à date, la version 1.1.0; il vous faut ajouter un nouveau repo avec les dernières version de vlc, enlever votre version actuelle et ré installer vlc :

sudo add-apt-repository ppa:c-korn/vlc
sudo apt-get update
sudo apt-get remove vlc
sudo apt-get install vlc mozilla-plugin-vlc videolan-doc

Depuis la sortie officielle de VLC en 1.1.0, VLC lit parfaitement les fichiers webm, toutes plateformes confondues !

Avec votre navigateur web

Mais le véritable intérêt de webm, c’est le web, aussi à cette page, vous sont listées les navigateurs compatibles webm.
Vous y trouverez un paquet debian/ubuntu pour chrome, et en téléchargeant et détarrant un firefox nightly build, vous pourrez aussi les lire avec firefox.

Si vous pouvez lire la video ci dessous, c’est qu’alors vous utilisez un navigateur compatible webm !

Avec chrome version 6.0.437.3 dev , j’ai pu la lire avec succès !

Vous pouvez aussi télécharger la vidéo en enregistrant cette url :

Exemple de vidéo webm à télécharger

Bon encodage Webm à tous !

Sources :

Debugging any Java Application

As long as you’re using a java application (ie an application calling your JVM), you can enable the debug mode with these parameters :

-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y

So for example, if you want to debug an ant launch (launched via « ant -f myBuild.xml » for example), you simply have to set ANT_OPTS; on windows :

set ANT_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y

Another example, with JBoss :

set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y

and then you can debug your launch with Eclipse, for example, creating a new debug configuration (remote java application on port 8787) !
Option : you can choose whether or not the application should wait for your debugger setting suspend to y or n.