linux gst-launch 播放视频旋转,ubuntu下 gstreamer 的配置及播放音视频例子(已经验证)...

Gstreamer安装:

使用sudo apt-get install 安装

sudo apt-get install libgstreamer0.10-dev gstreamer-tools gstreamer0.10-tools gstreamer0.10-doc

sudo apt-get installgstreamer0.10-plugins-basegstreamer0.10-plugins-goodgstreamer0.10-plugins-uglygstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse

安装了如下的gst的插件:

gstreamer0.10-tools

gstreamer0.10-x

gstreamer0.10-plugins-base

gstreamer0.10-plugins-good

gstreamer0.10-plugins-ugly

gstreamer0.10-plugins-bad

gstreamer0.10-ffmpeg

gstreamer0.10-alsa

gstreamer0.10-schroedinger

gstreamer0.10-pulseaudio

有可能需要安装的软件:

sudo apt-get install bison

sudo apt-get install flex

sudo apt-get install zlib1g

mad解码插件

apt-get install libmad0-dev

apt-get install gstreamer0.10-plugins-ugly

Initializing GStreamer

#include

#include

intmain(intargc,char*argv[])

{

constgchar*nano_str;

guintmajor,minor,micro,nano;

gst_init(&argc,&argv);

gst_version(&major,&minor,µ,&nano);

if(nano==1)

nano_str="(CVS)";

elseif(nano==2)

nano_str="(Prerelease)";

else

nano_str="";

printf("ThisprogramislinkedagainstGStreamer%d.%d.%d%s\n",

major,nano_str);

return0;

}

copy

gbooleanbus_call(GstBus*bus,GstMessage*msg,gpointerdata)

GMainLoop*loop=(GMainLoop*)data;//这个是主循环的指针,在接受EOS消息时退出循环

switch(GST_MESSAGE_TYPE(msg))

{

caseGST_MESSAGE_EOS:

g_print("Endofstream\n");

g_main_loop_quit(loop);

break;

caseGST_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);

break;

}

default:

}

returnTRUE;

char*argv[])

GMainLoop*loop;

GstElement*pipeline,*source,*decoder,*sink;//定义组件

GstBus*bus;

loop=g_main_loop_new(NULL,FALSE);//创建主循环,在执行g_main_loop_run后正式开始循环

if(argc!=2)

g_printerr("Usage:%s\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("Oneelementcouldnotbecreated.Exiting.\n");

//设置source的location参数。即文件地址.

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,0); background-color:inherit">//开始播放

gst_element_set_state(pipeline,GST_STATE_PLAYING);

g_print("Running\n");

//开始循环

g_main_loop_run(loop);

g_print("Returned,stoppingplayback\n");

gst_element_set_state(pipeline,GST_STATE_NULL);

gst_object_unref(GST_OBJECT(pipeline));

return0;

}

编译运行

gcc-Walltest2.c-otest2 $(pkg-config--cflags--libsgstreamer-0.10)

(注意!!!很多地方写的这条命令 :gcc-Wall$(pkg-config--cflags--libsgstreamer-0.10)-gtest2.c-otest2 ,根本编译不过!)

编译时借助了pkg-config pkg-config --cflags --libs gstreamer-0.10 会把gstreamer-0.10编译所依赖的库的路径 头文件的路径全部帮你找出来,不用你再依次写出。(上面这条pkg-config --cflags --libs gstreamer-0.10 就相当于:-pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-Linux-gnu/glib-2.0/include -I/usr/include/gs

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值