• 安装gstreamer开发环境


    ubuntu中安装gstreamer开发环境:

    * 安装gstreamer基本库,工具,以及插件

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


    * 安装ffmpeg支持

    sudo apt-get install gstreamer0.10-ffmpeg


    * 测试

    gst-launch autovideosrc ! ffmpegcolorspace ! autovideosink

    gst-launch v4l2src ! ffmpegcolorspace ! autovideosink


    * 录制摄像头视频

    以上内容转自 http://foyo99.zhuidaniu.com/blogs/724

    1,设置环境变量

    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
    export LD_LIBRARY_PATH=/usr/local/lib

    2,安装mad插件

    下载libmad-0.15.1b.tar.gz
    http://sourceforge.net/project/showfiles.php?group_id=12349

    ./configure --prefix=/usr/local/

    make

    make install

    下载libid3tag-0.15.1b.tar.gz
    http://sourceforge.net/project/showfiles.php?group_id=12349

    ./configure --prefix=/usr/local/

    make

    make install

    下载gst-plugins-ugly-0.10.9.tar.bz2   2008.8.26
    http://gstreamer.freedesktop.org/src/

    ./configure

    make

    make install

    这样,在/usr/local/lib/gstreamer-0.10目录下就出现了

    libgstmad.a libgstmad.la libgstmad.so

    mad插件也就安装成功了!

    检测mad插件是否安装上的命令

    gst-inspect mad

    会显示已安装的mad插件的详细信息

    3,用gst-launch测试播放mp3

    gst-launch filesrc location="beyond.mp3" ! mad ! audioconvert ! alsasink

    可以听到音乐了。


    4,用mp3_dec.c文件测试

    ----------------
    #include <gst/gst.h>

    int
    main(int argc,char *argv[])
    {
    GstElement *pipeline,*filesrc,*decoder,*convert,*audiosink;

    gst_init(&argc,&argv);

    if(argc != 2){
       g_print("usage: %s <mp3 filename> ",argv[0]);
       exit(-1);
    }

    pipeline=gst_pipeline_new("pipeline");

    if(!pipeline)
    {
       g_print("Maybe pipeline cann't be created! ");
       exit(-1);
    }

    filesrc=gst_element_factory_make("filesrc","disk_source");

    if(!filesrc)
    {
       g_print("Maybe filesrc cann't be created! ");
       exit(-1);
    }
    g_object_set(G_OBJECT(filesrc),"location",argv[1],NULL);

    decoder=gst_element_factory_make("mad","decoder-audio");
    if(!decoder)
    {
       g_print("Maybe decoder cann't be created! ");
       exit(-1);
    }

    convert = gst_element_factory_make("audioconvert", "a-convert");
    if(! convert)
    {
       g_print("Maybe convert cann't be created! ");
       exit(-1);
    }

    audiosink=gst_element_factory_make("osssink","play_audio");
    if(! audiosink)
    {
       g_print("Maybe audiosink cann't be created! ");
       exit(-1);
    }

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

    while(gst_bin_iterate_recurse(GST_BIN(pipeline)));

    gst_element_set_state(pipeline,GST_STATE_NULL);

    gst_object_unref(GST_OBJECT(pipeline));

    exit(0);
    }
    ----------------

    编译命令

    gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10)mp3_dec.c -o mp3_dec

    生成可执行文件

    mp3_dec

    播放mp3

    ./mp3_dec beyond.mp3

    就可以听到音乐了!

    note:
    如果遇到
    Element = gst_element_factory_make("mad", "decoder");
    Element为null,说明没安装mad插件,可以通过
    gst-inspect mad
    命令查看mad插件是否正常安装,如没有安装,在ubuntu下可以通过如下命令进行安装:
    sudo apt-get install gstreamer0.10-plugins-ugly
     
  • 相关阅读:
    zookeeper 集群安装(单点与分布式成功安装)
    ubuntu下tty1tty5命令控制台无法登录
    (1)《QT+OpenGL学习之我见》初始化窗口及三个重要函数 vs+Qt
    完全免费和开源的权限管理系统
    系统在iis6上部署
    代码生成那点事
    大整数乘法计算
    对字符串和字符数组的理解
    不被严格文档类型支持的元素
    Java实现一个简单的聊天小程序
  • 原文地址:https://www.cnblogs.com/little-ant/p/3605494.html
Copyright © 2020-2023  润新知