blog.Ring.idv.tw

2007 August

影音轉檔工具-FFmpeg

簡單且快速的安裝方式如下:

Step 1.下載LAME MP3 Encoder

Step 2.組態設定並安裝

./configure --enable-shared --prefix=/usr
make
make install

Step 3.取得FFmpeg原始碼

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

Step 4.組態設定並安裝

./configure --enable-gpl --enable-libmp3lame --enable-shared --prefix=/usr
make
make install

Step 5.進行轉檔

ffmpeg -i blue.avi -ar 22050 -ab 32 -f flv -s 320x240 blue.flv

參考資料:

One-stop Installation Guide for Create a Linux Server-side FLV conversion environment

FFmpeg usage command

http://soenkerohde.com/tutorials/ffmpeg

ffmpeg和Mencoder使用实例小全

泛用型 ffmpeg 安裝攻略

2007-08-26 19:12:43 | Add Comment

Adobe AIR update for Flash CS3 Professional Beta 1

想要在Flash CS3底下開發Adobe AIR嗎?想要「Ctrl+Enter」就發佈成AIR嗎?

官方已經釋出 AIR:Flash CS3 Professional Update,趕緊去下載來試試看吧~

目前是beta 1版~ 我想等到Adobe AIR正式版問世後~ 這也應該會同步發佈成正式版的~

文件說明:

Using the Adobe AIR™update for Flash

Getting Started with Adobe AIR™ for Flash CS3 Professional

2007-08-21 10:20:23 | Add Comment

Flash Webcam 線上拍照存檔!~

.2008/12/10 新增範例下載

今天試著用Flash CS3寫一個Flash Webcam 線上拍照存檔的範例~

大致上分成兩部份來處理~一部份為Flash的前端,用來截取Webcam的畫面並將它存進BitmapData中,以供透過URLRequest來上傳處理~

而這部份比較關鍵的是,我們利用「as3corelib」所提供的「JPGEncoder」來進行壓縮,以增進傳送速度~

想當然而,後端就是直接將它讀出並存進一個影像檔即可。

程式碼如下所示:

ActionScript 3

import com.adobe.images.JPGEncoder;

var camera:Camera = Camera.getCamera("0");
camera.setMode(320,240,30);
var video = new Video(320, 240);
video.attachCamera(camera);
stage.addChild(video);
stage.addEventListener(MouseEvent.MOUSE_DOWN,clickHandler);
function clickHandler(event:MouseEvent)
{
	var bd:BitmapData = new BitmapData(320, 240);
	bd.draw(video);
	var encoder:JPGEncoder = new JPGEncoder(100);
	var bytes:ByteArray = encoder.encode(bd);
	var req:URLRequest = new URLRequest("http://localhost/WebCamHandler.as3");
	req.data = bytes;
	req.method = URLRequestMethod.POST;
	req.contentType = "application/octet-stream";
	var loader:URLLoader = new URLLoader();			
	loader.addEventListener(Event.COMPLETE, completeHandler);
	loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
	loader.load(req);
}
function completeHandler(event:Event):void
{
	trace("上傳成功");
}
function errorHandler(event:IOErrorEvent):void
{
	trace("上傳失敗");
}

Servlet

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class WebCamHandler extends HttpServlet
{
    private String base;
    
    public void init(ServletConfig sc) throws ServletException
    {
        ServletContext sco = sc.getServletContext();
        base = sco.getRealPath("/");
    }
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    {   
        int readed;
        try
        {
            String filePath = base+new Date().getTime()+".jpg";
            BufferedInputStream bis = new BufferedInputStream(req.getInputStream());
            FileOutputStream fos = new FileOutputStream(new File(filePath));
            byte[] bytes = new byte[2048];
            while((readed=bis.read(bytes)) != -1)
            {
                fos.write(bytes, 0, readed);
            }
            fos.close();
            bis.close();
            
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

範例下載

WebCamHandler(CS4、Webapp)

2007-08-19 15:19:20 | Comments (17)

打造屬於你自己的Google Suggest!

想要做出類似Google Suggest的功能嗎?

這裡有一篇教學文章~以及作者所分享的程式碼~ Try it!

Creating a Google AJAX Suggest Like Website Search

2007-08-17 16:47:27 | Comments (1)

Java連結FoxPro(ODBC)

由於適逢需要利用Java連結Foxpro來操作一些資料庫~

所以找了一下資訊~這裡將利用透過ODBC的方式來連接~

所以我們必須先下載並安裝「Visual FoxPro ODBC Driver」,以便從「系統管理工具」>「資料來源ODBC」來設定~

基本設定方式

1.驅動程式請選「Microsoft Visual FoxPro Driver」

2.Data Source Name,請自定一個識別字串

3.Database type,如果你只有dbf檔案的話,請選「Free Table directory」

4.Path,請填你存放這些dbf檔案的路徑即可

設定之後便可測試一下:

import java.sql.*;
public class JDBCDemo
{
    private PreparedStatement ps;
    private ResultSet rs;
    private Connection conn;
    
    public JDBCDemo()
    {
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            conn = DriverManager.getConnection("jdbc:odbc:"+DataSourceName);
            ps = conn.prepareStatement("select * from test");
            rs = ps.executeQuery();
            while(rs.next())
            {
                System.out.println(rs.getString(1));
            }
        } catch (Exception e)
        {
            System.out.print(e);
        }
    }
    public static void main(String args[])
    {
        new JDBCDemo();        
    }
}

2007-08-17 00:55:14 | Add Comment

Previous Posts
Copyright (C) Ching-Shen Chen. All rights reserved.

::: 搜尋 :::

::: 分類 :::

::: 最新文章 :::

::: 最新回應 :::

::: 訂閱 :::

Atom feed
Atom Comment