B4A Library VidEffects

Enjoy this project from B4A https://github.com/krazykira/VidEffects

This library uses OpenGL Shaders to apply effects on Videos at Runtime

Please note that these effects are temporary , video file is not modified .

VidEffects
Author:
SMM
Version: 0.01
  • VidEffects
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • applyAutoFixEffect (scale As Float)
    • applyBlackAndWhiteEffect
    • applyBrightnessEffect (brightnessvalue As Float)
    • applyContrastEffect (contrast As Float)
    • applyCrossProcessEffect
    • applyDocumentaryEffect
    • applyDuotoneEffect (firstcolor As Int, secondcolor As Int)
    • applyFillLightEffect (strength As Float)
    • applyGrainEffect (strength As Float)
    • applyGreyScaleEffect
    • applyInvertColorsEffect
    • applyLamoishEffect
    • applyNoEffect
    • applyPosterizeEffect
    • applySaturationEffect (scale As Float)
    • applySepiaEffect
    • applySharpnessEffect (scale As Float)
    • applyTemperatureEffect (scale As Float)
    • applyTintEffect (color As Int)
    • applyVignetteEffect (scale As Float)
    • loadVideo (path As String)
    • onResume
    • start
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int



Sample
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim demo As VidEffects
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    demo.Initialize("demo")
 
    If File.Exists(File.DirRootExternal,"sample.mp4")= False Then
        File.Copy(File.DirAssets,"sample.mp4",File.DirRootExternal,"sample.mp4")
    End If
    Activity.AddView(demo,0,0%y,100%x,100%y)
    demo.loadVideo(File.Combine(File.DirRootExternal,"sample.mp4"))
 
 
    demo.applyInvertColorsEffect
End Sub

Sub demo_ready
 
    demo.start
End Sub
Sub Activity_Resume
    demo.onResume
End Sub


Version 2 adds a method for applying a custom shader : applyCustomShader

Sample
B4X:
Dim shader As String="#extension GL_OES_EGL_image_external : require\n" _
                & "precision mediump float;\n" _
                & "varying vec2 vTextureCoord;\n" _
                & "uniform samplerExternalOES sTexture;\n" & "void main() {\n" _
                & "  vec4 color = texture2D(sTexture, vTextureCoord);\n" _
                & "  float colorR = (color.r + color.g + color.b) / 3.0;\n" _
                & "  float colorG = (color.r + color.g + color.b) / 3.0;\n" _
                & "  float colorB = (color.r + color.g + color.b) / 3.0;\n" _
                & "  gl_FragColor = vec4(colorR, colorG, colorB, color.a);\n" _
                & "}\n"
       
    demo.applyCustomShader(shader.Replace("\n",CRLF))

This is the same as applying BlackAndWhiteEffect .
 

Attachments

  • VidEffects.zip
    31 KB · Views: 217
  • VidEffects2.zip
    31.9 KB · Views: 204
Last edited:

Rantor777

Member
Licensed User
First post shows 0.01, i think it needs correction, as you stated below , version 2, could it be updated version
 
Top