gstreamer的安装和简单的mp3编写
2010-02-05 11:26
211 查看
当于windows下的directshow。
Gstreamer简单介绍:
GStreamer 作为 GNOME
桌面环境推荐的流媒体应用框架,采用了基于插件(plugin)和管道(pipeline)的体系结
构,框架中的所有的功能模块都被实现成可以插拔的组件(component),
并且在需要的时候能够很方便地安装到任意一个管道上,由于所有插件都通过管道机制进行
统一的数据,因此很容易利用已有的各种插件“组装”出一个功能完善的多媒体应用程序。
这篇文章“用 GStreamer 简化 Linux 多媒体开发”对GStreamer的概念介绍的挺好的.
http://www.ibm.com/developerworks/cn/linux/l-gstreamer/
在linux安装gstreamer:
1.去http://gstreamer.freedesktop.org/
下载源码包
一般要安装gstreamer以下最基本的包,分别下载:
gstreamer
gst-plugins-base
gst-plugins-good
2.安装gstreamer:
解压后,进入目录直接执行./configure,可能会出错,如提示缺少bison,flex等,运行apt
-get install bison安装
make
make install
3.安装gst-plugins-base:
安装前要设置环境变量,由于gstreamer是默认安装,没有设置--prefix,所以将export
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH就行了
./configure,提示缺少liboil,去https://launchpad.net/ubuntu/+source/liboil/0.3.14
-3下载安装即可
make
make install
4.安装gst-plugins-good:
./configure
make
make install
到此可以用gst-launch -vm audiotestsrc ! audioconvert ! audioresample ! osssink
测试能在杨声器里听到蜂鸣音
总之,在安装过程中,缺什么就apt-get install,找不到就去网上下载安装。
此外,在安装完gstreamer后,安装其他plugins之前要设置PKG_CONFIG_PATH正确。
“ld.so.conf 文件与PKG_CONFIG_PATH变量”
http://hi.baidu.com/litaosmile/blog/item/751be4f45bbb4ee67609d7be.html
”安装gstreamer到ARMv6平台“的可以参考:
http://hi.baidu.com/9562512/blog/item/ee9af9d39351f73d970a16b8.html
5.编写代码测试,最简单的mp3播放:
a.需要使用mad解码插件,因此首先要安装libid3tag0-dev和libmad0-dev
apt-get install liblid3tag0-dev
apt-get install libmad0-dev
b.接着安装gstreamer0.10-plugins-ugly才会安装上mad
参考:“Streamer学习笔记(一)”
http://www.cnblogs.com/phinecos/archive/2009/06/07/1498166.html
中的代码,无
法播放mp3.
作了些修改,加了个convert就可以了:
view plain
copy to clipboard
?
#include <gst/gst.h>
#include <gtk/gtk.h>
#define GTK_WINDOW 0
static
GtkWidget *window;
static
gboolean
delete_event(GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
return
FALSE;
}
static
void
destroy(GtkWidget *widget,
gpointer data)
{
gtk_main_quit ();
}
static
void
window_create(void
)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "delete_event"
,
G_CALLBACK (delete_event), NULL);
g_signal_connect (G_OBJECT (window), "destroy"
,
G_CALLBACK (destroy), NULL);
gtk_widget_show (window);
}
int
main(int
argc,
char
*argv[])
{
GstElement *pipeline, *filesrc, *decoder, *convert, *audiosink;
#if GTK_WINDOW
gtk_init(&argc, &argv);
window_create();
#endif
gst_init(&argc, &argv);
<
4000
span>
if
(argc != 2) {
g_print("usage: %s <mp3 filename>/n"
, argv[0]);
exit (-1);
}
pipeline = gst_pipeline_new("pipeline"
);
filesrc = gst_element_factory_make("filesrc"
,
"disk_source"
);
decoder = gst_element_factory_make("mad"
,
"decoder"
);
convert = gst_element_factory_make("audioconvert"
,
"a-convert"
);
audiosink = gst_element_factory_make("osssink"
,
"play_audio"
);
g_object_set(G_OBJECT(filesrc), "location"
, argv[1], NULL);
gst_bin_add_many(GST_BIN(pipeline), filesrc, decoder, convert, audiosink, NULL);
gst_element_link_many(filesrc, decoder, convert, audiosink, NULL);
gst_element_set_state(pipeline, GST_STATE_PLAYING);
#if GTK_WINDOW
gtk_main ();
#else
while
(gst_bin_iterate_recurse(GST_BIN(pipeline)));
#endif
gst_element_set_state(pipeline, GST_STATE_NULL);
gst_object_unref(GST_OBJECT (pipeline));
exit (0);
}
#include <gst/gst.h> #include <gtk/gtk.h> #define GTK_WINDOW 0 static GtkWidget *window; static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) { return FALSE; } static void destroy(GtkWidget *widget, gpointer data) { gtk_main_quit (); } static void window_create(void) { window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), NULL); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL); gtk_widget_show (window); } int main(int argc, char *argv[]) { GstElement *pipeline, *filesrc, *decoder, *convert, *audiosink; #if GTK_WINDOW gtk_init(&argc, &argv); window_create(); #endif gst_init(&argc, &argv); if (argc != 2) { g_print("usage: %s <mp3 filename>/n", argv[0]); exit (-1); } pipeline = gst_pipeline_new("pipeline"); filesrc = gst_element_factory_make("filesrc", "disk_source"); decoder = gst_element_factory_make("mad", "decoder"); convert = gst_element_factory_make("audioconvert", "a-convert"); audiosink = gst_element_factory_make("osssink", "play_audio"); g_object_set(G_OBJECT(filesrc), "location", argv[1], NULL); gst_bin_add_many(GST_BIN(pipeline), filesrc, decoder, convert, audiosink, NULL); gst_element_link_many(filesrc, decoder, convert, audiosink, NULL); gst_element_set_state(pipeline, GST_STATE_PLAYING); #if GTK_WINDOW gtk_main (); #else while (gst_bin_iterate_recurse(GST_BIN(pipeline))); #endif gst_element_set_state(pipeline, GST_STATE_NULL); gst_object_unref(GST_OBJECT (pipeline)); exit (0); }//////////////////////////
在windows下安装gstreamer:
1. 之前参考“gtk的windows环境”
http://young001.blogbus.com/logs/43176719.html
已经建立了用minGW在windows下的gtk开发环境。
2.参考:
a. ”在Windows平台上建立GStreamer开发环境“
http://hi.baidu.com/tinyfun/blog/item/a7167f12cb060a0a5baf5339.html
b. http://www.qihoo.com/q/misc/6565790.html?f=1
Procssing对于视频的支持一向很烂,起码在PC下搭配QuickTime不是什么特别好的选择(这
点和Mac不一样)。如果平时你用它做一些视频的捕获或者是非常大的视频加载,通常不会
让你满意,而且画面很不流畅。以往的解决方法是通过Opengl的texture来渲染。
现在好了,先是有人写好了Gstreamer java的binding,
http://code.google.com/p/gstreamer-java/
Gstreamer也是一个pipeline的工作流程,具体的请参考
http://www.cin.ufpe.br/~cinlug/wiki/index.php/Introducing_GStreamer
然后pr论坛的dres Colubri又写出来了给processing用的Gstreamer
Library,所有的问题都过去了,现在通过使用Gstreamer,在Pr里面直接调用HD的视频都没
有问题。
安装的过程比较复杂,目前只能在PC下使用
1.先下载安装gtk+2runtime 没有这个是安装不了Gstreamer的
地址
http://sourceforge.net/project/downloading.php?groupname=gimp-win&filename=gtk
+-
2.10.13-setup.exe&use_mirror=internap
2.去这里下载所有的文件 http://gstreamer.freedesktop.org/pkg/windows/releases/
注意只需要下载windows下安装程序就可以,否则的话你还需要自己编译
3.先安装gtk
4.在安装Gstreamer
5.按顺序安装所有的插件
gst-plugins-base-0.10.13
gst-plugins-good-0.10.6
gst-plugins-bad-0.10.5
gst-plugins-ugly-0.10.6
gst-ffmpeg-0.10.2
6.把Gstreamer Library copy到你的processing的library里面 地址
http://codeanticode.wordpress.com/category/gstreamer/
7.重新启动机器,因为安装Gstreamer的时候会添加系统环境变量
8.Bingo! 现在可以使用了
我机器上的测试 avi,mpeg,divx,quicktime都没问题,我最大加载的是1GB的影片,dres
Colubri测试加载的影片更大是1920x 1280的HD mov
相关文章推荐
- 终于知道linux firefox不能播放 web在线词典的单词发音了! --通过banshee安装gstreamer1-libav/-plugins-ugly/plugins-bad三个mp3插件.
- C# Windows 服务 的简单程序的编写,安装 和 卸载
- ubuntu+gstreamer 简单的mp3实现
- ant的安装、使用,build.xml简单编写
- ant的安装、使用,build.xml简单编写
- ant 的 安装 使用 简单编写
- RHEL6 安装gstreamer 实现 rhythmbox 听mp3歌曲
- Ubuntu12.04+OpenCv-2.4.9安装及简单程序编写测试
- 使用GStreamer 编写一个简单的MP3播放器
- GStreamer 编写一个简单的MP3播放器
- ant的安装、使用,build.xml简单编写
- 详解:Windows系统安装OpenSSL 以及在VC环境下编写一个简单OpenSSL程序
- ant的安装、使用,build.xml简单编写
- 初学java之jdk安装,基本概念,简单代码编写
- 编写、编译、安装、移除一个内核模块的基本过程,不能再简单了的
- C语言学习之1(Microsoft Visual Studio即VC6软件的安装及hello world 简单例子编写)
- Linux 学习笔记3----Gstreamer 编写播放mp3程序。
- 简单实现WEB程序在线安装
- robotframework [安装和创建简单测试用例]