Skip to content

Custom OpenGL Shader and Filters

WangBin edited this page Jun 20, 2016 · 6 revisions

VideoShader API is not stable now because I'm lack of shader experience.

A custom VideoShader can be used through OpenGLVideo.setUserShader(VideoShader*). You can access OpenGLVideo through VideoRenderer.opengl() and GLSLFilter.opengl().

VideoShaderObject and DynamicShaderObject take advantages of QObject meta property and dynamic property features. It's possible to dynamically edit and apply shader code when rendering using DynamicShaderObject. DynamicShaderObject is also used in QML as VideoShader type.

Examples: shaders, glsl filter

QML AudioFilter/VideoFilter

A QML AudioFilter/VideoFilter can be type of AVFilter and UserFilter. VideoFilter can also be type of VideoFilter .GLSLFilter. AVFilter is the default type. The supported filters can be retrieved by supportedAVFilters property. The avfilter property is avfilter options.

A VideoFilter can set a VideoShader as it's shader property to use custom shader when GLSLFilter type is enabled.

A VideoFilter can be installed to MediaPlayer/AVPlayer or VideoOutput2 as it's target. Only 1 target can be installed to for 1 filter. You can use an array of filters as a filter chain for MediaPlayer.videoFilters/AVPlayer.videoFilters and VideoOutput2.filters

import QtAV 1.7
...
VideoFilter {
    id: vf
    avfilter: "negate"
    ...
}
MediaPlayer {
    ...
    videoFilters: [vf]
}

Examples: avfilter, glsl filter