• QtGstreamer 编译


    一  安装依赖项
    1 安装cmake
    hdhuang@hdh-UBT:~/gstreamer/qt-gstreamer-0.10.2/build$ sudo apt-get install cmake
    正在读取软件包列表... 完成
    正在分析软件包的依赖关系树       
    正在读取状态信息... 完成       
    将会安装下列额外的软件包:
      cmake-data
    下列软件包将被升级:
      cmake cmake-data


    2 glib
    查看glib的banb
    pkg-config --modversion glib-2.0
    2.32.1


    3 安装Automoc
    hdhuang@hdh-UBT:~/gstreamer/qt-gstreamer-0.10.2/build$ sudo apt-get install automoc
    正在读取软件包列表... 完成
    正在分析软件包的依赖关系树       
    正在读取状态信息... 完成       
    下列【新】软件包将被安装:
      automoc
    升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 702 个软件包未被升级。


    4 安装 Qt
     sudo apt-get install libqt4-dev libqt4-debug libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig
     sudo apt-get install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer
     sudo apt-get install qt4-dev-tools qt4-examples qt4-designer qt4-assistant python-qt4 qt4-demos qt4-qtconfig qt4-linguist 


    hdhuang@hdh-UBT:~/gstreamer/qt-gstreamer-0.10.2/build$ sudo apt-get install qt4-dev-tools
    正在读取软件包列表... 完成
    正在分析软件包的依赖关系树       
    正在读取状态信息... 完成       
    将会安装下列额外的软件包:
      libqt4-dbus libqt4-declarative libqt4-designer libqt4-dev libqt4-help
      libqt4-network libqt4-opengl libqt4-qt3support libqt4-script
      libqt4-scripttools libqt4-sql libqt4-sql-sqlite libqt4-svg libqt4-test
      libqt4-xml libqt4-xmlpatterns libqtcore4 libqtgui4 qdbus qt4-designer
      qt4-doc qt4-linguist-tools qt4-qmake
    建议安装的软件包:
      libqt4-declarative-folderlistmodel libqt4-declarative-gestures
      libqt4-declarative-particles libqt4-declarative-shaders qt4-qmlviewer
      libmysqlclient-dev libpq-dev libsqlite3-dev unixodbc-dev qt4-qtconfig
      qt4-doc-html
    推荐安装的软件包:
      libqt4-opengl-dev libqtwebkit-dev
    下列【新】软件包将被安装:
      qt4-designer qt4-dev-tools qt4-doc
    下列软件包将被升级:
      libqt4-dbus libqt4-declarative libqt4-designer libqt4-dev libqt4-help
      libqt4-network libqt4-opengl libqt4-qt3support libqt4-script
      libqt4-scripttools libqt4-sql libqt4-sql-sqlite libqt4-svg libqt4-test
      libqt4-xml libqt4-xmlpatterns libqtcore4 libqtgui4 qdbus qt4-linguist-tools
      qt4-qmake
    升级了 21 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 681 个软件包未被升级。


    正在设置 libqtcore4 (4:4.8.1-0ubuntu4.4) ...
    4.8.1版本,ok


    二  编译
    mkdir build
    cd build
    sudo cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/gtstreamer


    -----------------------------------------------------------------------------
    -- The following REQUIRED packages could NOT be located on your system.
    -- You must install these packages before continuing.
    -----------------------------------------------------------------------------
       * Boost (1.39 or higher)  <http://www.boost.org/>
         Required for building QtGLib
       * GStreamer (0.10.33 or higher)  <http://gstreamer.freedesktop.org/>
         Required to build QtGStreamer
       * GStreamer app library (0.10.33 or higher)  <http://gstreamer.freedesktop.org/>
         Required to build QtGStreamerUtils
       * GStreamer interfaces library (0.10.33 or higher)  <http://gstreamer.freedesktop.org/>
         Required to build QtGStreamer


    -----------------------------------------------------------------------------


    A 安装 boost
    sudo apt-get install libboost-dev
    sudo cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/gtstreamer
    -----------------------------------------------------------------------------
    -- The following REQUIRED packages could NOT be located on your system.
    -- You must install these packages before continuing.
    -----------------------------------------------------------------------------
       * GStreamer (0.10.33 or higher)  <http://gstreamer.freedesktop.org/>
         Required to build QtGStreamer
       * GStreamer app library (0.10.33 or higher)  <http://gstreamer.freedesktop.org/>
         Required to build QtGStreamerUtils
       * GStreamer interfaces library (0.10.33 or higher)  <http://gstreamer.freedesktop.org/>
         Required to build QtGStreamer


    2 Gstreamer
    为什么说Gstreamer没有安装呢?
    只有这个库我是自己安装而没有采用apt-get install 的方法,就是因为这样而找不到这个库。
    gedit ~/.branshrc
    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
    sourc ~/.branshrc


    运行命令查看:
    pkg-config --libs  gstreamer-1.0
    -L/usr/local/lib -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 
    这样能找到,所以路径配置已经是没有问题了。
    pkg-config --libs  gstreamer
    Package gstreamer was not found in the pkg-config search path.
    Perhaps you should add the directory containing `gstreamer.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'gstreamer' found
    这样是找不到的。
    安装文件是安装在usrlib 下面的。
    usrlibpkgconfig 
    目录usrlib 下面有gstreamer-0.10但是
    pkg-config --libs  gstreamer-0.10
    也是找不到的。


    将qt-gstreamer-0.10.2cmakemodules的gstreamer的版本改为1.0.
    从新编译
    checking for module 'gstreamer-interfaces-1.0'
    --   package 'gstreamer-interfaces-1.0' not found
    * GStreamer interfaces library (0.10.33 or higher)  <http://gstreamer.freedesktop.org/>
         Required to build QtGStreamer


    那个这个gstreamer-interfaces是只那个gstreamer组件呢?应该是我没有安装这个组件导致的。
    不清楚是那个组件了!
    安装组件gst-plugins-ugly 还是不可以!这个到底是那个组件呢?
    网上查找了一下,应该是在gst-plugins-base组件里面的。
    应该四0.10的版本有,单色1.0的版本就没有了!


    我还算用0.10的版本从新编译一个好了!
    1 安装0.10的版本
    sudo apt-get install gstreamer0.10 
    报错:
    gstreamer0.10-fluendo-plugins-mp3-partner : 冲突: gstreamer0.10-fluendo-mp3
    先卸载它好了:
    sudo apt-get remove gstreamer0.10 
    sudo apt-get install gstreamer0.10 
    还是不行


    下载源代码,编译运行。


    2 再次编译看
    A sudo cmake .. -sudo cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/qtgtstreamer
    -----------------------------------------------------------------------------
    -- The following external packages were located on your system.
    -- This installation will have the extra features provided by these packages.
    -----------------------------------------------------------------------------
       * Qt 4 - Required for building everything
       * QtDeclarative - Required for building QML support
       * Boost - Required for building QtGLib
       * GStreamer - Required to build QtGStreamer
       * GStreamer base library - Used for building the qwidgetvideosink element
       * GStreamer app library - Required to build QtGStreamerUtils
       * GStreamer interfaces library - Required to build QtGStreamer
       * GStreamer video library - Used for building the qwidgetvideosink element
       * GLib - Required to build QtGLib
       * GObject - Required to build QtGLib
       * OpenGL - Required for OpenGL rendering support in qtvideosink (desktop only)


    -----------------------------------------------------------------------------
    -- The following OPTIONAL packages could NOT be located on your system.
    -- Consider installing them to enable more features from this software.
    -----------------------------------------------------------------------------
       * QtOpenGL (4.7 or higher)  <http://qt.nokia.com/>
         Required for OpenGL acceleration in qtvideosink and QtGStreamerUi
       * OpenGLES (2.0 or higher)  <http://www.opengl.org>
         Required for OpenGLES rendering support in qtvideosink (embedded only)
       * Doxygen  <http://www.doxygen.org/>
         Used to generate the API documentation


    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/hdhuang/Gstreamer0.10/qt-gstreamer-0.10.2/build
    B sudo make
    C sudo make install


    3 测试

    sudo gst-launch-0.10 -v playbin uri=file:///home/hdhuang/realize.ogg
    ok可以正常播放。
    B examples
    要在控制台使用sudo ./player 运行。
    可以出声音,但是视频有问题,估计是编译时候渲染出问题了,从新编译一下渲染。
    C 安装opengl
    sudo apt-get install libqt4-opengl-dev

    还是没有图形呢?


    4 安装路径有点问题

    从新安装一下:

    sudo cmake .. -sudo cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/

    sudo make

    sudo make install

    rm -rf build

    mkdir build

     cmake .. -DCMAKE_INSTALL_PREFIX=/opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/ -DCMAKE_BUILD_TYPE=Release -DQT_VERSION=5
    make

    make install

    //CMakeLists.txt

    SET(CMAKE_SYSTEM_NAME Linux)
    SET(TOOLCHAIN_DIR "/opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain")
    SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_DIR})
    SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
    SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

    SET(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/arm-fsl-linux-gnueabi-gcc)
    SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/arm-fsl-linux-gnueabi-g++)
    SET(CMAKE_LIBRARY_PATH "/opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/lib")
    SET(CMAKE_PREFIX_PATH ${TOOLCHAIN_DIR}/qt-5.2.1-embedded-arm-MuliTCS/lib/cmake)
    SET(CMAKE_INCLUDE_PATH ${TOOLCHAIN_DIR}/include)
    SET(Boost_INCLUDE_DIR "/opt/data/E9_CD/fsl/boost_1_50_0")
    SET(OPENGL_gl_LIBRARY "/opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/lib")

    project(QtGStreamer)
    cmake_minimum_required(VERSION 2.8.9)
    enable_testing()

    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)

    set(QTGSTREAMER_VERSION 0.10.3)

    LINK_DIRECTORIES(/opt/EmbedSky/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/tq-linaro-toolchain/lib)


    option(QTGSTREAMER_STATIC "Build QtGStreamer as a static library" OFF)
    option(QTGSTREAMER_TESTS "Build QtGStreamer's tests" OFF)
    option(QTGSTREAMER_EXAMPLES "Build QtGStreamer's examples" ON)
    option(QTGSTREAMER_CODEGEN "Build and use QtGStreamer's codegen" OFF)
    option(USE_GST_PLUGIN_DIR "Install gstreamer plugins at the system location" ON)
    option(USE_QT_PLUGIN_DIR "Install qt plugins at the system location" ON)

    include(GNUInstallDirs)
    include(MacroLogFeature)

    set(Qt4_MIN_VERSION 4.7)
    set(Qt5_MIN_VERSION 5.0.0)
    find_package(Qt4or5 COMPONENTS Core Gui Widgets OPTIONAL_COMPONENTS OpenGL Quick1 Test)
    macro_log_feature(Qt4or5_FOUND "Qt" "Required for building everything"
                                   "http://qt-project.org/" TRUE "${Qt4or5_MIN_VERSION}")
    macro_log_feature(Qt4or5_OpenGL_FOUND "QtOpenGL"
                                    "Required for OpenGL acceleration in qtvideosink and QtGStreamerUi"
                                    "http://qt-project.org/" FALSE "${Qt4or5_MIN_VERSION}")
    macro_log_feature(Qt4or5_Quick1_FOUND "QtQuick1 (QtDeclarative)"
                                    "Required for building QtQuick1 support"
                                    "http://qt-project.org/" FALSE "${Qt4or5_MIN_VERSION}")

    if (QTGSTREAMER_TESTS)
        macro_log_feature(Qt4or5_Test_FOUND "QtTest" "Required for building unit tests"
                                          "http://qt-project.org/" FALSE "${Qt4or5_MIN_VERSION}")
        if (NOT Qt4or5_Test_FOUND)
            set(QTGSTREAMER_TESTS OFF)
        endif()
    endif()

    find_package(Boost 1.39)
    macro_log_feature(Boost_FOUND "Boost" "Required for building QtGLib" "http://www.boost.org/" TRUE "1.39")

    # set the QTGSTREAMER_* cmake variables
    set(BUILDING_QTGSTREAMER TRUE)
    if (${QT_VERSION} STREQUAL "5")
        set(USE_QT5 TRUE)
        set(QTGLIB_LIBRARY Qt5GLib)
        set(QTGSTREAMER_LIBRARY Qt5GStreamer)
        set(QTGSTREAMER_UI_LIBRARY Qt5GStreamerUi)
        set(QTGSTREAMER_UTILS_LIBRARY Qt5GStreamerUtils)
        set(QTGSTREAMER_PACKAGE_NAME Qt5GStreamer)
        set(QTVIDEOSINK_NAME qt5videosink)
        set(QTGLVIDEOSINK_NAME qt5glvideosink)
        set(QWIDGETVIDEOSINK_NAME qwidget5videosink)
    elseif (${QT_VERSION} STREQUAL "4")
        set(USE_QT4 TRUE)
        set(QTGLIB_LIBRARY QtGLib)
        set(QTGSTREAMER_LIBRARY QtGStreamer)
        set(QTGSTREAMER_UI_LIBRARY QtGStreamerUi)
        set(QTGSTREAMER_UTILS_LIBRARY QtGStreamerUtils)
        set(QTGSTREAMER_PACKAGE_NAME QtGStreamer)
        set(QTVIDEOSINK_NAME qtvideosink)
        set(QTGLVIDEOSINK_NAME qtglvideosink)
        set(QWIDGETVIDEOSINK_NAME qwidgetvideosink)
    endif()
    set(QTGSTREAMER_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src)
    include(QtGStreamerConfigCommon)

    find_package(GStreamer 0.10.33 COMPONENTS base)
    macro_log_feature(GSTREAMER_FOUND "GStreamer" "Required to build QtGStreamer"
                                      "http://gstreamer.freedesktop.org/" TRUE "0.10.33")
    macro_log_feature(GSTREAMER_BASE_LIBRARY_FOUND "GStreamer base library"
                                                   "Used for building the ${QTVIDEOSINK_NAME} element"
                                                   "http://gstreamer.freedesktop.org/" FALSE "0.10.33")

    find_package(GStreamerPluginsBase 0.10.36 COMPONENTS app interfaces video pbutils)
    macro_log_feature(GSTREAMER_APP_LIBRARY_FOUND "GStreamer app library"
                                                  "Required to build QtGStreamerUtils"
                                                  "http://gstreamer.freedesktop.org/" TRUE "0.10.33")
    macro_log_feature(GSTREAMER_INTERFACES_LIBRARY_FOUND "GStreamer interfaces library"
                                                    "Required to build QtGStreamer"
                                                    "http://gstreamer.freedesktop.org/" TRUE "0.10.33")
    macro_log_feature(GSTREAMER_VIDEO_LIBRARY_FOUND "GStreamer video library"
                                                    "Used for building the ${QTVIDEOSINK_NAME} element"
                                                    "http://gstreamer.freedesktop.org/" FALSE "0.10.33")
    macro_log_feature(GSTREAMER_PBUTILS_LIBRARY_FOUND "GStreamer pbutils library"
                                                    "Used for building the Discoverer API"
                                                    "http://gstreamer.freedesktop.org/" TRUE "0.10.36")

    find_package(GLIB2)
    macro_log_feature(GLIB2_FOUND "GLib" "Required to build QtGLib" "http://www.gtk.org/" TRUE)

    find_package(GObject)
    macro_log_feature(GOBJECT_FOUND "GObject" "Required to build QtGLib" "http://www.gtk.org/" TRUE)

    set(CMAKE_REQUIRED_INCLUDES ${QTGSTREAMER_INCLUDES})
    include(CheckCXXSourceCompiles)
    check_cxx_source_compiles("
    #include <QtCore/QtGlobal>
    #if !defined(QT_OPENGL_ES)
    #error "No OpenGLES"
    #endif
    int main() {}
    " USE_OPENGLES)

    if (USE_OPENGLES)
        find_package(OpenGLES2)
        macro_log_feature(OPENGLES2_FOUND "OpenGLES"
                              "Required for OpenGLES rendering support in ${QTVIDEOSINK_NAME}"
                              "http://www.opengl.org" FALSE "2.0")
    else()
        find_package(OpenGL)
        macro_log_feature(OPENGL_FOUND "OpenGL"
                              "Required for OpenGL rendering support in ${QTVIDEOSINK_NAME}"
                              "http://www.opengl.org" FALSE)
    endif()

    if (QTGSTREAMER_CODEGEN AND CMAKE_CROSSCOMPILING)
        message(WARNING "Codegen use requested, but we are crosscompiling. Disabling...")
        set(QTGSTREAMER_CODEGEN OFF)
    endif()

    if (QTGSTREAMER_CODEGEN)
        find_package(FLEX)
        macro_log_feature(FLEX_FOUND "Flex" "Required to build codegen, a helper code generator"
                                     "http://flex.sourceforge.net/" TRUE)

        find_package(BISON)
        macro_log_feature(BISON_FOUND "Bison" "Required to build codegen, a helper code generator"
                                      "http://www.gnu.org/software/bison/" TRUE)
    endif()


    if (CMAKE_COMPILER_IS_GNUCXX)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat-security -Wundef -Wpointer-arith -fno-common")
    endif ()


    set(QTGSTREAMER_INSTALL_TARGET_DEFAULT_ARGS
            RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
            ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
    set(QTGSTREAMER_PC_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
    set(QTGSTREAMER_CMAKE_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${QTGSTREAMER_PACKAGE_NAME})
    set(QTGSTREAMER_INCLUDES_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${QTGSTREAMER_PACKAGE_NAME})

    if (USE_GST_PLUGIN_DIR)
        set(QTGSTREAMER_GST_PLUGINS_INSTALL_DIR ${GSTREAMER_PLUGIN_DIR})
    else()
        set(QTGSTREAMER_GST_PLUGINS_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/gstreamer-0.10)
    endif()

    if (USE_QT_PLUGIN_DIR)
        set(QTGSTREAMER_QTQUICK1_INSTALL_DIR ${QT_IMPORTS_DIR})
    else()
        if (USE_QT5)
            set(QTGSTREAMER_QTQUICK1_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/qt5/imports)
        else()
            set(QTGSTREAMER_QTQUICK1_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/qt4/imports)
        endif()
    endif()


    if (QTGSTREAMER_CODEGEN AND FLEX_FOUND AND BISON_FOUND)
        add_subdirectory(codegen)
    endif()

    add_subdirectory(src)
    add_subdirectory(elements)

    if (QTGSTREAMER_TESTS)
        add_subdirectory(tests)
    endif()

    if (QTGSTREAMER_EXAMPLES)
        add_subdirectory(examples)
    endif()

    # Add uninstall target. Taken from the KDE4 scripts
    configure_file("${CMAKE_SOURCE_DIR}/cmake/modules/cmake_uninstall.cmake.in" "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" @ONLY)
    add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")

    # Add doc target
    include(UseDoxygen)
    macro_log_feature(DOXYGEN_FOUND "Doxygen" "Used to generate the API documentation"
                                    "http://www.doxygen.org/" FALSE)

    macro_display_feature_log()

  • 相关阅读:
    10月20日
    tensorflow2自定义损失函数
    TensorFlow2_200729系列---20、自定义层
    Windows下Anaconda中tensorflow的tensorboard使用
    Windows下Anaconda中tensorflow的tensorboard使用(实测)
    可视化利器Visdom
    python虚拟环境-virtual environment
    TensorFlow2_200729系列---18、手写数字识别(层方式)
    tensorFlow2.1下的tf.data.Dataset.from_tensor_slices()的用法
    TensorBoard:TensorFlow 的可视化工具包
  • 原文地址:https://www.cnblogs.com/subo_peng/p/4689618.html
Copyright © 2020-2023  润新知