wang-bin / QtAV

A cross-platform multimedia framework based on Qt and FFmpeg. 基于Qt和FFmpeg的跨平台高性能音视频播放框架. Recommand to use new sdk https://github.com/wang-bin/mdk-sdk
http://qtav.org
3.94k stars 1.5k forks source link

glsl filter: android #841

Open PassionK opened 7 years ago

PassionK commented 7 years ago

你好, 大神 我把glsl filter想要用在安卓, 首先我试过在windows且确认好用,但是我不能用在安卓的。 那么把glsl filter我能不能用在安卓呢? 我的环境是QT5,7和安卓6.0, 我的代码是如下,

import QtQuick 2.7 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtAV 1.7

Window { visible: true width: 640 height: 480 title: qsTr("Hello World")

Rectangle {
    anchors.fill: parent
    color: "black"

    VideoFilter {
        id: negate
        type: VideoFilter.GLSLFilter
        shader: Shader {
            postProcess: "gl_FragColor.rgb = vec3(1.0-gl_FragColor.r, 1.0-gl_FragColor.g, 1.0-gl_FragColor.b);"
        }
    }

    VideoFilter {
        id: grayscale
        type: VideoFilter.GLSLFilter
        shader: Shader {
            postProcess: "gl_FragColor.rgb = vec3(gl_FragColor.r * 0.3 +  gl_FragColor.g * 0.59 + gl_FragColor.b * 0.11, gl_FragColor.r * 0.3 +  gl_FragColor.g * 0.59 + gl_FragColor.b * 0.11, gl_FragColor.r * 0.3 +  gl_FragColor.g * 0.59 + gl_FragColor.b * 0.11);"
        }
    }

    VideoFilter {
        id: hflip
        type: VideoFilter.GLSLFilter
        shader: Shader {
            sample: "vec4 sample2d(sampler2D tex, vec2 pos, int p) {return texture(tex, vec2(1.0-pos.x, pos.y));}"
        }
    }

    VideoOutput2 {
        id: videoOutput
        anchors.fill: parent
        source: video
        opengl: true
        filters: [grayscale, hflip]
    }

    MediaPlayer {
        id: video
        autoPlay: true
    }

   MouseArea {
       anchors.fill: parent
       onClicked: {
           fileDialog.open();
       }
   }
    FileDialog {
        id: fileDialog
        onAccepted: video.source = fileUrl
    }
}

}

这个代码是在windows行好,但是在安卓不行的。 我拜托,您帮忙我吧。 谢谢。

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/43678948-glsl-filter-android?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github).
wang-bin commented 7 years ago

log

PassionK commented 7 years ago

您好, 大神 我获的log是如下。您看帮忙一下。 04-06 10:33:04.915 21781-21794/org.qtproject.example.QtAVTest E/HAL: load: id=gralloc != hmi->id=gralloc 04-06 10:33:04.946 21781-21781/org.qtproject.example.QtAVTest I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl 04-06 10:33:05.223 21781-21781/org.qtproject.example.QtAVTest W/System: ClassLoader referenced unknown path: 04-06 10:33:05.350 21781-21781/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/platforms/android/libqtforandroid.so: is missing DT_SONAME will use basename as a replacement: "libqtforandroid.so" 04-06 10:33:05.358 21781-21781/org.qtproject.example.QtAVTest I/Qt: qt start 04-06 10:33:05.360 21781-21781/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/bearer/libqandroidbearer.so: is missing DT_SONAME will use basename as a replacement: "libqandroidbearer.so" 04-06 10:33:06.666 21781-21802/org.qtproject.example.QtAVTest E/HAL: load: id=gralloc != hmi->id=gralloc 04-06 10:33:06.666 21781-21802/org.qtproject.example.QtAVTest I/OpenGLRenderer: Initialized EGL, version 1.4 04-06 10:33:06.769 21781-21820/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/qml/QtQuick.2/libqtquick2plugin.so: is missing DT_SONAME will use basename as a replacement: "libqtquick2plugin.so" 04-06 10:33:06.782 21781-21820/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/qml/QtQuick/Window.2/libwindowplugin.so: is missing DT_SONAME will use basename as a replacement: "libwindowplugin.so" 04-06 10:33:06.789 21781-21820/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/qml/QtQuick/Dialogs/libdialogplugin.so: is missing DT_SONAME will use basename as a replacement: "libdialogplugin.so" 04-06 10:33:06.800 21781-21820/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/qml/QtAV/libQmlAV.so: is missing DT_SONAME will use basename as a replacement: "libQmlAV.so" 04-06 10:33:06.819 21781-21820/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/qml/QtQuick/Controls/libqtquickcontrolsplugin.so: is missing DT_SONAME will use basename as a replacement: "libqtquickcontrolsplugin.so" 04-06 10:33:06.848 21781-21820/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/qml/QtQuick/Dialogs/Private/libdialogsprivateplugin.so: is missing DT_SONAME will use basename as a replacement: "libdialogsprivateplugin.so" 04-06 10:33:06.856 21781-21820/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/qml/QtQuick/Layouts/libqquicklayoutsplugin.so: is missing DT_SONAME will use basename as a replacement: "libqquicklayoutsplugin.so" 04-06 10:33:06.866 21781-21820/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/qml/Qt/labs/folderlistmodel/libqmlfolderlistmodelplugin.so: is missing DT_SONAME will use basename as a replacement: "libqmlfolderlistmodelplugin.so" 04-06 10:33:06.873 21781-21820/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/qml/Qt/labs/settings/libqmlsettingsplugin.so: is missing DT_SONAME will use basename as a replacement: "libqmlsettingsplugin.so" 04-06 10:33:07.343 21781-21817/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving Object::GetInterface (SL_RESULT_FEATURE_UNSUPPORTED) 04-06 10:33:07.384 21781-21817/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/qml/QtQuick/Controls/Styles/Android/libqtquickcontrolsandroidstyleplugin.so: is missing DT_SONAME will use basename as a replacement: "libqtquickcontrolsandroidstyleplugin.so" 04-06 10:33:07.878 21781-21817/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/imageformats/libqdds.so: is missing DT_SONAME will use basename as a replacement: "libqdds.so" 04-06 10:33:07.884 21781-21817/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/imageformats/libqgif.so: is missing DT_SONAME will use basename as a replacement: "libqgif.so" 04-06 10:33:07.890 21781-21817/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/imageformats/libqicns.so: is missing DT_SONAME will use basename as a replacement: "libqicns.so" 04-06 10:33:07.897 21781-21817/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/imageformats/libqico.so: is missing DT_SONAME will use basename as a replacement: "libqico.so" 04-06 10:33:07.903 21781-21817/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/imageformats/libqjpeg.so: is missing DT_SONAME will use basename as a replacement: "libqjpeg.so" 04-06 10:33:07.909 21781-21817/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/imageformats/libqtga.so: is missing DT_SONAME will use basename as a replacement: "libqtga.so" 04-06 10:33:07.916 21781-21817/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/imageformats/libqtiff.so: is missing DT_SONAME will use basename as a replacement: "libqtiff.so" 04-06 10:33:07.923 21781-21817/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/imageformats/libqwbmp.so: is missing DT_SONAME will use basename as a replacement: "libqwbmp.so" 04-06 10:33:07.929 21781-21817/org.qtproject.example.QtAVTest W/linker: /data/data/org.qtproject.example.QtAVTest/qt-reserved-files/plugins/imageformats/libqwebp.so: is missing DT_SONAME will use basename as a replacement: "libqwebp.so" 04-06 10:33:41.163 21781-21817/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving Object::GetInterface (SL_RESULT_FEATURE_UNSUPPORTED) 04-06 10:33:41.220 21781-21817/org.qtproject.example.QtAVTest W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client; transfer 1, track 44100 Hz, output 48000 Hz

                                                                        [ 04-06 10:33:41.222 21781:21817 I/         ]
                                                                        counter >= 5, send pause/stop state to pg, counter: 0

04-06 10:33:41.238 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.238 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.239 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.239 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.239 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.239 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.240 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.240 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.240 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.240 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.240 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.240 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.240 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.240 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.241 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.241 21781-22486/org.qtproject.example.QtAVTest W/libOpenSLES: Leaving BufferQueue::Enqueue (SL_RESULT_BUFFER_INSUFFICIENT) 04-06 10:33:41.580 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShader::compile(Fragment): 2:118: L0001: Unknown character 'Ê'(202) 2:118: L0001: Unknown character '¬'(172) 2:118: L0001: Unknown character ''(4) 2:119: L0002: Undeclared variable 'hj' 2:119: L0001: Expected token '}', found 'end of file' 04-06 10:33:41.580 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): Problematic Fragment shader source code 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): #ifndef GL_FRAGMENT_PRECISION_HIGH

define highp highp

                                                                            #endif
                                                                            #line 1
                                                                            precision highp   int;
                                                                            precision highp   float;
                                                                            #if __VERSION__ < 130
                                                                            #define texture texture2D
                                                                            #else
                                                                            #define texture2D texture
                                                                            #endif // < 130
                                                                            #define USE_RG
                                                                            /******************************************************************************
                                                                                QtAV:  Multimedia framework based on Qt and FFmpeg
                                                                                Copyright (C) 2012-2016 Wang Bin <wbsecg1@gmail.com>

                                                                            *   This file is part of QtAV

                                                                                This library is free software; you can redistribute it and/or
                                                                                modify it under the terms of the GNU Lesser General Public
                                                                                License as published by the Free Software Foundation; either
                                                                                version 2.1 of the License, or (at your option) any later version.

                                                                                This library is distributed in the hope that it will be useful,
                                                                                but WITHOUT ANY WARRANTY; without even the implied warranty of
                                                                                MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                                                                                Lesser General Public License for more details.

                                                                                You should have recei

04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShader::link: Link failed because of missing fragment shader. 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_Matrix ): shader program is not linked 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_colorMatrix ): shader program is not linked 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_to8 ): shader program is not linked 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_opacity ): shader program is not linked 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_c ): shader program is not linked 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_texelSize ): shader program is not linked 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_textureSize ): shader program is not linked 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_Texture0 ): shader program is not linked 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_Texture1 ): shader program is not linked 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_Texture2 ): shader program is not linked 04-06 10:33:41.581 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShader::link: Link failed because of missing fragment shader. 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShader::compile(Fragment): 2:51: L0002: No matching function for call to 'sample2d' 2:52: L0002: Undeclared variable 'c' 2:59: L0002: Undeclared variable 'c' 2:63: L0002: Undeclared variable 'c' 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): Problematic Fragment shader source code *** 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): #ifndef GL_FRAGMENT_PRECISION_HIGH

define highp highp

                                                                            #endif
                                                                            #line 1
                                                                            precision highp   int;
                                                                            precision highp   float;
                                                                            #if __VERSION__ < 130
                                                                            #define texture texture2D
                                                                            #else
                                                                            #define texture2D texture
                                                                            #endif // < 130
                                                                            #define HAS_ALPHA
                                                                            #define USE_RG
                                                                            /******************************************************************************
                                                                                QtAV:  Multimedia framework based on Qt and FFmpeg
                                                                                Copyright (C) 2012-2016 Wang Bin <wbsecg1@gmail.com>

                                                                            *   This file is part of QtAV

                                                                                This library is free software; you can redistribute it and/or
                                                                                modify it under the terms of the GNU Lesser General Public
                                                                                License as published by the Free Software Foundation; either
                                                                                version 2.1 of the License, or (at your option) any later version.

                                                                                This library is distributed in the hope that it will be useful,
                                                                                but WITHOUT ANY WARRANTY; without even the implied warranty of
                                                                                MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                                                                                Lesser General Public License for more details.

                                                                                You

04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): *** 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShader::link: Link failed because of missing fragment shader. 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_Matrix ): shader program is not linked 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_colorMatrix ): shader program is not linked 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_to8 ): shader program is not linked 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_opacity ): shader program is not linked 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_c ): shader program is not linked 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_texelSize ): shader program is not linked 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_textureSize ): shader program is not linked 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShaderProgram::uniformLocation( u_Texture0 ): shader program is not linked 04-06 10:33:41.593 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShader::link: Link failed because of missing fragment shader. 04-06 10:33:41.640 21781-21828/org.qtproject.example.QtAVTest W/libQtAVTest.so: (null):0 ((null)): QOpenGLShader::link: Link failed because of missing fragment shader. 谢谢。

wang-bin commented 7 years ago

QOpenGLShader::compile(Fragment): 2:118: L0001: Unknown character 'Ê'(202) 2:118: L0001: Unknown character '¬'(172) 2:118: L0001: Unknown character '�'(4) 2:119: L0002: Undeclared variable 'hj' 2:119: L0001: Expected token '}', found 'end of file' 你代码有问题,自己检查吧