Links

   Quran Explorer - Interactive Audio Recitations & Translations

Wednesday, March 16, 2011

Batch Convert Multimedia Files Using FFMPEG

I will show u how to batch convert multimedia files using a bash script.

The following script will get all .mp4 files from the current directory, convert them to .wav and save them in a folder called wav(still in the current directory). Of course u can modify this file to suit your specific conversion needs.

Save the following script as mp4_to_wav.sh and make it executable (chmod +x mp4_to_wav.sh):

#===================================
#the directory wav must be present in the current directory
for f in *.mp4;
do
ffmpeg -i "$f" "wav/${f%.mp4}.wav";
done
#====================================

Now i can accept ur coffee

Friday, February 25, 2011

Programmatically accessing Managed Beans

Happy New Year

The traditional (best) way of accessing using managed beans is via the EL in JSF based webapps.

There are instances where u need to access a Managed Bean programaticaly (may be to avoid cyclic references in faces-config.xml thus causing deadlocks).

After so much agony I learnt how to do it and i thought of sharing it with u

FacesContext context = FacesContext.getCurrentInstance();
SessionBean bean1 = (SessionBean) context.getApplication().evaluateExpressionGet(context, "#{session}", SessionBean.class);

Of course SessionBean must already have bn declared as managed bean session in faces-config.xml

=======================================================
Artificial Intelligence is no match for Human Stupidity

OpenICE Web Framework

OpenICE - Alpha

Allow me to introduce all of you to my New Web Application Development Framework based on JSF 2.0 and powered by ICE Faces.

In OpenICE developers need not care about Managed Beans and custom POJOs since the Framework Has Robust Managed Beans which update their status and that of the application from an external XML.

The application developer will need to design, develop and manage the underlying Database (Model) and use the markup (XML) for OpenICE applications to create UI/UX elements.

In the MVC OpenICE takes care of the Control and lets the user worry about WHAT to store (Model) and WHERE to show it (View) thus cutting down development time drastically.

Footprint:
Glassfish v3
JSF 2.0
ICE Faces 2.0 using 1.8 Components

Monday, January 24, 2011

FFMPEG - Multimedia Tool

FFmpeg is a free software/open source project that produces libraries and programs for handling multimedia data. It ships with Fedora Linux so I naturally took a dive and have never turned back.....

I normaly use it to convert multimedia files from one format to another. Being a command line tool u expect faster execution.

For example
Convert from MP4 to AVI

#ffmpeg -i inputfile.mp4 outfile.avi


To See Supported File Formats
#ffmpeg -formats

You will get output similar to this
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration:
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
built on Nov 20 2009 15:52:49, gcc: 4.3.2 20081105 (Red Hat 4.3.2-7)
File formats:
E 3g2 3GP2 format
E 3gp 3GP format
DEA wmav1 Windows Media Audio 1
DEA wmav2 Windows Media Audio 2
DEVSD wmv1 Windows Media Video 7
DEVSD wmv2 Windows Media Video 8
D V wmv3 Windows Media Video 9
DES dvbsub DVB subtitles
DES dvdsub DVD subtitles
DEV D dvvideo DV (Digital Video)
D V dxa Feeble Files/ScummVM DXA
D V D eacmv Electronic Arts CMV video
D V D eatgq Electronic Arts TGQ video
D V eatgv Electronic Arts TGV video
D V D eatqi Electronic Arts TQI Video
D V D escape124 Escape 124
.........To mention but a few



XOR in Oracle

I had a situation where an XOR implementation was needed in a SELECT query. Since Oracle 10g doesnt have this operator predefined i did some gymnastics and ended up with this solution.

I decided to share this (among others) since human knowledge belongs to mankind

1. XOR in oracle

Example 1 - chars only

Eg we want to display results where ismale='1' XOR iscitizen='1' (ie either but not both)

Solution
SELECT ismale, iscitizen, (ismale + iscitizen) as xor
FROM tablename
WHERE ismale + iscitizen = 1;

NB: oracle will add(mathematical) chars as it would integers

Example 2 - varchars

Eg we want to display results where gender='male' XOR countryid='KE' (ie either but not both)

Solution
SELECT gender, countryid, (decode(gender,'male','1','0') + decode(countryid,'KE','1','0')) as xor
FROM tablename
WHERE (decode(gender,'male','1','0') + decode(countryid,'KE','1','0')) = 1;

NB: oracle will add chars as it would integers