1. 程式人生 > >Ubuntu 12.04下安裝Gstreamer

Ubuntu 12.04下安裝Gstreamer

一. Gstreamer安裝:

方法一:使用sudo apt-get install 安裝

sudoapt-get install libgstreamer0.10-dev gstreamer-tools gstreamer0.10-toolsgstreamer0.10-doc
sudo apt-getinstall gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-badgstreamer0.10-plugins-bad-multiverse

方法二:在官方網站下載原始碼包,使用./configure, make, makeinstall進行安裝:

gstreamer-1.2.2.tar.xz, gst-plugins-base-1.2.1.tar.xz, gst-plugins-good-1.2.2.tar.xz,gst-plugins-ugly-1.2.2.tar.xz或者在列表中選擇歷史release版本下載

基礎包下載:

gst-plugins-base-0.10.35.tar.bz2

gst-plugins-good-0.10.30.tar.bz2

gst-plugins-ugly-0.10.10.tar.bz2

安裝過程中可能出現以下錯誤:

1. configure: error: Could not find bison

[email protected]

:$sudo apt-get install bison

2. configure: error: Could not find flex

[email protected]:$sudo apt-get install flex

3. configure: error: *** Working zlib libraryand headers not found ***

[email protected]:$sudo apt-get install zlib1g

Gstreamer-0.10.35配置成功後出現以下訊息:


然後make, make install即可

接下來依次安裝gst-plugins-base-0.10.35, gst-plugins-good-0.10.30

,此時需注意安裝順序,必須先安裝gst-plugins-base-0.10.35,再安裝gst-plugins-good-0.10.30,此順序不可修改,否則出現依賴錯誤。

以上包安裝完成後使用:

gst-launch-vm audiotestsrc ! audioconvert ! audioresample ! osssink

可測試到耳機出現蜂鳴聲。

二. Gstreamer測試播放mp3音樂:

需要使用mad解碼外掛,因此需要先安裝gstreamer0.10-plugins-ugly,它依賴其他兩個庫。

[email protected]:$ apt-get installliblid3tag0-dev

[email protected]:$ apt-get install libmad0-dev

[email protected]:$apt-get install gstreamer0.10-plugins-ugly

編譯測序程式:

#include <gst/gst.h>
#include <glib.h>
//定義訊息處理函式,
static gboolean bus_call(GstBus *bus,GstMessage *msg,gpointer data)
{
    GMainLoop *loop = (GMainLoop *) data;//這個是主迴圈的指標,在接受EOS訊息時退出迴圈    switch (GST_MESSAGE_TYPE(msg))
    {
        case GST_MESSAGE_EOS:
            g_print("End of stream\n");
            g_main_loop_quit(loop);
            break;
        case GST_MESSAGE_ERROR:
        {
               gchar *debug;
               GError *error;
               gst_message_parse_error(msg,&error,&debug);
               g_free(debug);
               g_printerr("ERROR:%s\n",error->message);
               g_error_free(error);
               g_main_loop_quit(loop);

                break;
        }
        default:
             break;
    }
    return TRUE;
}

int main(int argc,char *argv[])
{
    GMainLoop *loop;
    GstElement *pipeline,*source,*decoder,*sink;//定義元件    GstBus *bus;

    gst_init(&argc,&argv);
    loop = g_main_loop_new(NULL,FALSE);//建立主迴圈,在執行 g_main_loop_run後正式開始迴圈
    if(argc != 2)
    {
        g_printerr("Usage:%s <mp3 filename>\n",argv[0]);
        return -1;
    }
    //建立管道和元件    pipeline = gst_pipeline_new("audio-player");
    source = gst_element_factory_make("filesrc","file-source");
    decoder = gst_element_factory_make("mad","mad-decoder");
    sink = gst_element_factory_make("autoaudiosink","audio-output");

    if(!pipeline||!source||!decoder||!sink){
        g_printerr("One element could not be created.Exiting.\n");
        return -1;
    }
    //設定 sourcelocation 引數。即檔案地址.
    g_object_set(G_OBJECT(source),"location",argv[1],NULL);
    //得到管道的訊息匯流排    bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
   //新增訊息監視器    gst_bus_add_watch(bus,bus_call,loop);
    gst_object_unref(bus);
    //把元件新增到管道中.管道是一個特殊的元件,可以更好的讓資料流動    gst_bin_add_many(GST_BIN(pipeline),source,decoder,sink,NULL);
   //依次連線元件   gst_element_link_many(source,decoder,sink,NULL);
   //開始播放    gst_element_set_state(pipeline,GST_STATE_PLAYING);
    g_print("Running\n");
    //開始迴圈    g_main_loop_run(loop);
    g_print("Returned,stopping playback\n");
    gst_element_set_state(pipeline,GST_STATE_NULL);
    gst_object_unref(GST_OBJECT(pipeline));
    return 0;
}

編譯執行

gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) -g test2.c -o test2
./test2 /home/admin/mingyue.mp3

參考資料:

http://www.cnblogs.com/phinecos/archive/2009/06/07/1498166.html

http://blog.sina.com.cn/s/blog_638ea1960101eilq.html

相關推薦

Ubuntu 12.04安裝Gstreamer

一. Gstreamer安裝:方法一:使用sudo apt-get install 安裝sudoapt-get install libgstreamer0.10-dev gstreamer-tools gstreamer0.10-toolsgstreamer0.10-docs

Linux Ubuntu 12.04 安裝mysql 以及建立 遠端navicat 連線

安裝過程中需要用到的linux 命令: 1:sudo ****   以sudo 開頭的程式碼 表示 是以管理員執行 2:chmod 777 ***(*號代表檔名) 當你不是以ROOT許可權進入Ubuntu 的話 更改檔案配置  需要修改檔案的 許可權級別,777 代表最高

Ubuntu 12.04 安裝 Eclipse

$ sudo apt-get install eclipse 方法二:(優點是安裝內容清爽,缺點是配置麻煩) 1、安裝JDK,參考 Ubuntu 12.04 下安裝 JDK 7 2、下載 Eclipse 從 http://www.eclipse.org/downloads/index-develo

Ubuntu 12.04安裝vim, 簡單配置與基本使用介紹

ubuntu12.04預設沒有安裝vim,執行命令會出現以下錯誤: [email protected]:~$ vim test1.c The program 'vim' can be found in the following packages:  * vi

Ubuntu 12.04安裝VMware Tools遇到的問題

exception: VMware Tools installation fails when Easy Install is in progress (1017687) 在VMware下安裝Ubuntu,那麼必須安裝VMware-tools,才能獲得更好的體驗,包括螢幕解析度、聲音、和window

Angularjs學習---angularjs環境搭建,ubuntu 12.04安裝nodejs、npm和karma

1.下載angularjs 2.示例1 HelloWorld ! 新建一個helloworld.html <!doctype html> <html ng-app> <head> <script src><

Ubuntu 12.04安裝MySQL圖解

轉載地址:http://blog.csdn.net/eddie_520/article/details/23447247 因為Ubuntu Server上 wget比較慢,所以我是直接在windows用迅雷下載好,然後WinSCP上傳到伺服器的,看各自喜好了。 上正題。

ubuntu 12.04安裝軟體報“在處理時有錯誤發生”解決方案

今天剛裝完ubuntu 12.04,想安裝Chrome瀏覽器,在《Ubuntu軟體中心》沒有找到,只有Chromium,於是就先Googling了一下,有人說先在:“直接去官網下的安裝不了,得要先在《Ubuntu軟體中心》安裝Chromium之後,再安裝Chrome,最後再

Ubuntu 12.04安裝mysql 5.5.28版本執行此命令時,缺少 libaio.so.1

在Ubuntu 12.04下安裝mysql 5.5.28版本執行此命令時,會提示如下錯誤的資訊: 執行  ./scripts/mysql_install_db 時出錯。 ./bin/mysqld: error while loading shared libraries:

ubuntu 16.04安裝 mysql-connector-c-6.1.11-linux-glibc2.12-x86_64.tar.gz

最近在玩MySQL,就想著用c語言去連結資料庫,看了網上的c語言連結資料的例子,怎麼也執行不了; 網上說要安裝一個庫,如下: 安裝:sudo apt-get install libmysqlclient-dev 不知道是不是我電腦的原因,這種裝過以後報了錯誤,好像是:mysql-com

Ubuntu 12.04swift的單節點部署安裝

由於課題需要,現開始進行對openstack的研究,現在網上對於swift安裝有很多教程,有成功的,有失敗的,現將我的心得告訴大家,方便大家的使用 1.首先安裝GIT      1.1有人推薦使用 sudo apt-get install git  

Ubuntu 12.04fcitx安裝谷歌搜狗輸入法

原址:yanue.net/post-110.html 在網上找了好多Ubuntu12.04安裝搜狗輸入法的帖子,總是不太全面,不能達到正確安裝使用搜狗輸入法的目的, 使用上面兩個帖子綜合了一下,終於安裝成功。 我遇到的問題是:安裝完搜狗輸入法以後,在system set

ubuntu 12.04編譯安裝nginx-1.9.3之後 tomcat叢集

   一、tomcat安裝   1.安裝nginx 請檢視http://blog.csdn.net/liangzi4454/article/details/47023447    2. jdk安裝不在贅述,不會的同學,可以網上查詢教程;    3. tomcat下載    

Ubuntu 12.04 用 Wine 安裝 RTX 2010

注意:最好 sudo su;su - 後安裝軟體等,本人對Linux使用者許可權管理不甚瞭解,但是如果沒賦管理員許可權安裝出錯了。我全程管理員許可權,但是第三步忘了出錯了,賦管理員許可權後第三步OK。

UBUNTU 12.04傻瓜式簡單安裝arm-linux-gcc等gnu arm toolchain交叉編譯工具

歡迎轉載,轉載時請保留作者資訊,謝謝。 1. 驗證無誤的工具鏈安裝(能正常編譯linux,busybox等): 可以去這個地址下載工具鏈,是作者上傳的,要2分,當是辛苦分了,要免費的可以去min2440官網下載,地址我在下面也貼出來了。 CSDN下載連結:htt

Ubuntu 16.04安裝nodejs

.cn ges ubuntu 技術 com apt-get 分享 6.0 images 源安裝: 1.curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash - 2.sudo apt-get insta

Ubuntu 16.04安裝Apache壓力測試工具ab

apt-get gpo 簡單使用 utils sta markdown 測試結果 壓力測試 安裝apache 安裝 sudo apt-get install apache2-utils 簡單使用 # 對http://www.baidu.com/進行100次請求,10個並發請

Ubuntu 15.04安裝Docker

parse tor 其他命令 錯誤 dot https tdi 一次 操作 最近聽說Docker很火,不知道什麽東西,只知道是一個容器,可以跨平臺。閑來無事,我也來倒弄倒弄。本文主要介紹:Ubuntu下的安裝,以及基本的入門命令介紹;我的機器是Ubuntu 15.04 64

Ubuntu 14.04安裝靜態原始碼分析工具Splint3.1.2

------------------------------------ 版權資訊 ------------------------------------ 此文連結: http://blog.csdn.net/doniexun/article/details/45219863

記錄Ubuntu 14.04 安裝無線網卡驅動解決無法連接WiFi的過程

less bsp 14. 要求 driver name ora ubunt 14.04 新電腦安裝了Ubuntu 14.04,但是網絡連接中只有以太網而沒有WiFi的選項. 打開System Setting系統設置-Software&Updates軟件&更新