Wednesday, June 5, 2013

Install latest FFmpeg and x264

FFmpeg is a versatile tool to encode and decode a multitude of video and audio formats. x264encodes high-quality H.264 video

1. Uninstall x264, libx264-dev, and ffmpeg if they are already installed. Open a terminal and run the following

     $ sudo apt-get remove ffmpeg x264 libx264-dev
2. Get all of the packages you will need to install FFmpeg and x264

 $ sudo apt-get update
 $ sudo apt-get install build-essential git-core checkinstall yasm texi2html \
    libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev \
    libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev \
    libvorbis-dev libvpx-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev
 
Install x264
3. Get the current source files, compile, and install x264.
  cd 
  git clone git://git.videolan.org/x264
  cd x264
  ./configure
  make
  [optional]  
  sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
    awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
    --fstrans=no --default
 
  make install [To install]

Install FFmpeg
4. Get the most current source files, compile, and install FFmpeg.

cd
git clone git://git.videolan.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc \
    --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
    --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis \
    --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab
make
make install
sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(./version.sh)" --backup=no \
    --deldoc=yes --fstrans=no --default
hash x264 ffmpeg ffplay ffprobe
 
5. To check ffmpeg
   $ ffmpeg and press enter 
 

Determine Inactivity and Activity Event for Adobe AIR Application

A FlexEvent.IDLE event will dispatch every 100 milliseconds when there has been no keyboard or mouse activity for 1 second. IDLE needs to be bound to a SystemManager instance and we will need to reference the mx_internal namespace later on:

1
2
3
import mx.managers.SystemManager;
import mx.events.FlexEvent;
import mx.core.mx_internal;

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       backgroundColor="#FFFFFF"
                       top="0"  bottom="0"
                       width="100%" height="100%"
                       showStatusBar="false"
                       preinitialize="preinitializeHandler(event)"
                       creationComplete="init(event)">

<fx:Script>
        <![CDATA[

             import mx.events.FlexEvent;
             /**
             * METHOD TO DETECT USER IDLE TIME AND SWITCH THE VIEWS
             **/
            public function initIdleExampleApp():void {
                systemManager.addEventListener(FlexEvent.IDLE,onUserIdle,false,0,true);
                systemManager.addEventListener(MouseEvent.CLICK,onUserActive,false,0,true);
                systemManager.addEventListener(MouseEvent.MOUSE_MOVE,onUserActive,false,0,true);
                systemManager.addEventListener(KeyboardEvent.KEY_DOWN,onUserActive,false,0,true);
                systemManager.addEventListener(KeyboardEvent.KEY_UP,onUserActive,false,0,true);
                systemManager.addEventListener(MouseEvent.MOUSE_WHEEL,onUserActive,false,0,true);
            }
            /**
             * METHOD TO HANDLE USER ACTIVE STATE AND SWITCH TO HOME SCREEN
             **/
            public function onUserActive(event:Event):void {

                       trace("User in active state ");
                      // TODO your logic here

               }
            /**
             * METHOD TO HANDLE THE USER IDLE TIME AND CHANGE THE VIEW TO SLIDE SHOW
             **/
            public function onUserIdle(event:Event):void {
                    if ( event.currentTarget.mx_internal::idleCounter ==1000 )
                    {
                        event.currentTarget.mx_internal::idleCounter = 0;

                          // TODO your logic here                                            
                      }
            }

            /**
             * METHOD TO INITIALIZE THE PRE-REQUISITIES
             **/
            protected function init(event:FlexEvent):void {
                 initIdleExampleApp();
            }

    ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
  </s:WindowedApplication>