Monday, July 7, 2008

Flex : Accessing attributes in XML data passed as ArrayCollection

Suppose this is the XML data you get as
in response to your HTTService :


<?xml version="1.0"?>
<catalog desc="desc3">
<clip desc="desc1">
<title>check</title>
</clip>
<clip desc="desc2">
<title>check2</title>
</clip>
</catalog>



And then, you use the result as the dataprovider
of your datarenderer :

photoFeed = event.result.catalog.clip as ArrayCollection;


Then inside you data renderer, if you want to access the
attributes of a CLIP
node, you have to do this :

t.text = data["desc"];

Wednesday, July 2, 2008

flex reading data from XML url



This is how the Config.xml looks like:
<?xml version="1.0" ?>
<config channelName="zee" bgColor="0xcc0066"
gridNumRows="3" gridNumCols="3" />

This example shows how to read the attributes of
an XML node.



<mx:HTTPService id="readConfig"
url="Config.xml" resultFormat="xml"
result="showClips(event)"/>
<mx:script>
<![CDATA[
import mx.rpc.events.ResultEvent;

[Bindable]

[Bindable]
private var configParams:XML;

private function showClips(event:ResultEvent):void {
configParams = (XML)(event.result);
mainGrid.rowCount = (int)((int)(configParams.@gridNumRows)-(int)('0'));
mainGrid.columnCount = (int)((int)(configParams.@gridNumCols)-(int)('0'));
cnLabel.text = configParams.@channelName;
}

Tuesday, July 1, 2008

ffmpeg with h264

1. I built ffmpeg myself with x264, but it doesn't work properly.
May be I should try with Mingw in place of Cygwin.

2. I analyzed SUPER. It uses ffmpeg, which is not built with h264 support. But SUPER
can still encode files with h264, since it uses x264.exe separately. I wanted to know
the exact commands, so I replaced their ffmpeg with my ffmpeg, but SUPER didn't
even launch.

3. If you are not too keen on building ffmpeg yourself,
simply pick it from here. It works with -vcodec h264.
The latest version available here seems to be problematic.

Friday, June 27, 2008

Using libx264 codec with ffmpeg

This is the information about the input file :

$ ./ffmpeg.exe -i input.avi

Duration: 01:47:20.81, start: 0.000000, bitrate: 909 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 560x304 [PAR 1:1 DAR 35:19], 23.98 tb(r)

Stream #0.1: Audio: mp3, 48000 Hz, stereo, 32 kb/s

then
$./ffmpeg.exe -i input.avi -ss 0 -t 20 -vcodec libx264 out.mpg

then I tried to play out.mpg with VLC, but it only played the audio only.
Winamp, Windows Media player couldn't even play it.
Uploading to Youtube : Failed (invalid file format)
Used as a source file to a videoDisplay object in Adobe Flex,
: unable to play the file.
Uploading to Vimeo : There was a problem converting this video. Please contact vimeo help !

Thursday, June 26, 2008

Building ffmpeg with libx264/h.264/x264 on Cygwin(Wiindows XP)

I am assuming here that you already have a build setup for ffmpeg
under Cygwin and looking for how to add x264 codec to it.
If you are new to ffmpeg build under cygwin, you might want to check this.

Now, you need to do this :
1. Install git for cygwin
2. $ git clone git://git.videolan.org/x264.git

Go inside the x264 folder and
remove these from the file "configure" :
"-mno-cygwin" (source)

./configure
./make

In my case it complained that nasm is missing, so I
downloaded and installed it for cygwin.

It will generate x264.h and libx264.a, which you have
to copy to /usr/include/ and /user/lib/ respectively.

Then inside the ffmpeg source folder :
./configure --disable-static --enable-shared --enable-memalign-hack --enable-libx264 --enable-gpl

then
./make

and that should be it.

------------------------------------------------------------------------

PS : Earlier I downloaded the x264 source code from here :
ftp://ftp.videolan.org/pub/videolan/x264/snapshots/

As it turned out, the version that is here and the version
that was expected by ffmpeg source code was different,
since after building x264 when I tried to build ffmpeg, I got these errors :

libavcodec/libx264.c: In function `X264_init':
libavcodec/libx264.c:151: error: structure has no member named `i_rc_method'

After which I tried to fetch some older versions from the SVN repository,
but for some reason it asked my username and password :

svn merge -rHEAD:280 x264.h
Authentication realm: df754926-b1dd-0310-bc7b-ec298dee348c
password for 'LENOVO':

It was then that I switched to the git repository of VLC.







Wednesday, May 7, 2008

Strange flex behavior

I have this function in flex.
It works correctly as it is.
But if I interchange the lines highlighted in bold,
it stops working.
strange but true.


public function playInTheMainPanel(event:MouseEvent):void{
mainVideo.source = (VideoDisplay)((Canvas)(event.currentTarget).getChildAt(0)).source;
mainVideo.stop();
mainVideo.play();
}

Blog Archive