Giter VIP home page Giter VIP logo

woshizhuer / hardwarevideocodec Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imalimin/hardwarevideocodec

0.0 1.0 0.0 76.87 MB

HardwareVideoCodec is an efficient video recording library for Android. Supports software and hardware encode. With it, you can record a video at any resolution, no need to care about camera resolution. Everything is so easy.

License: GNU General Public License v2.0

Java 16.19% Shell 0.11% CMake 0.06% GLSL 2.16% Makefile 5.36% C++ 16.14% C 59.30% MATLAB 0.08% Roff 0.27% HTML 0.33%

hardwarevideocodec's Introduction

HWVC(HardwareVideoCodec)

Download

HWVC is an efficient video encoding library for Android. Supports software and hardware encode. With it, you can encode a video at any resolution, no longer need to care about camera resolution. Everything is so easy.

ScreenRecord_1 ScreenRecord_1

Latest release

V1.7.3

  • Support seek now.
  • Fix player`s life cycle.
  • Support add filters to existing videos or cut videos.
  • Support video player.

Features

  • Support video encoding at any resolution. No need to care about camera resolution.
  • Support for add filters to existing videos or cut videos.
  • Support RTMP stream.
  • Support for changing resolution without restarting the camera.
  • Support hard & soft encode.
  • Record video & audio. Pack mp4 through MediaMuxer.
  • Use OpenGL to render and support filter.
  • Supports 40+ filters
  • Support beauty filter.
  • Support for changing resolution without restarting the camera.
  • More features.

Start

If you are building with Gradle, simply add the following code to your project:

  • You need to configure your kotlin environment. Project root build.gradle
buildscript {
    ext.kotlin_version = '1.2.30'//Latest kotlin version
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}
  • Module build.gradle
dependencies {
    implementation 'com.lmy.codec:hardwarevideocodec:1.7.3'
    implementation 'com.lmy.codec:rtmp:1.7.3'//If you want to use RTMP stream.
}
  • For record mp4
class MainActivity : AppCompatActivity() {
    private lateinit var mRecorder: VideoRecorderImpl
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val mTextureView = TextureView(this)
        setContentView(mTextureView)
        mRecorder = VideoRecorderImpl(this).apply {
            reset()
            setOutputUri("${Environment.getExternalStorageDirectory().absolutePath}/test.mp4")
            setOutputSize(720, 1280)//Default 720x1280
            setFps(30)
            setFilter(getDefaultFilter())
            setPreviewDisplay(mTextureView)
        }
        mRecorder.prepare()
        //For recording control
        mTextureView.setOnTouchListener { v, event ->
            when (event.action) {
                MotionEvent.ACTION_DOWN -> {
                    if (mRecorder.prepared())
                        mRecorder.start()
                }
                MotionEvent.ACTION_UP -> {
                    if (mRecorder.started())
                        mRecorder.pause()
                }
            }
            true
        }
    }

    private fun getDefaultFilter(): BaseFilter = GroupFilter.create(BeautyV4Filter())
            .addSticker(TextSticker().apply {
                setText(TextSticker.Text("HWVC", 56f).apply {
                    x = 0.8f
                    y = 0.03f
                })
            })
            .addSticker(ImageSticker().apply {
                setImage(ImageSticker.Image().apply {
                    x = 0.03f
                    y = 0.03f
                    scale = 1.6f
                    bitmap = BitmapFactory.decodeResource(resources, R.mipmap.ic_logo_hwvc)
                })
            })

    override fun onDestroy() {
        super.onDestroy()
        mRecorder.release()
    }
}
  • For live
class MainActivity : AppCompatActivity() {
    private lateinit var mRecorder: VideoRecorderImpl
    private val onStateListener = object : VideoRecorder.OnStateListener {

        override fun onStop() {
        }

        override fun onPrepared(encoder: Encoder) {
            mRecorder.start()
        }

        override fun onRecord(encoder: Encoder, timeUs: Long) {
        }

        override fun onError(error: Int, msg: String) {

        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val mTextureView = TextureView(this)
        setContentView(mTextureView)
        mRecorder = VideoRecorderImpl(this).apply {
            reset()
            setOutputUri("rtmp://192.168.16.125:1935/live/livestream")
            setOutputSize(720, 1280)//Default 720x1280
            setFps(30)
            setFilter(getDefaultFilter())//Default NormalFilter
            setPreviewDisplay(mTextureView)
            setOnStateListener(onStateListener)
        }
        mRecorder.prepare()
    }

    private fun getDefaultFilter(): BaseFilter = GroupFilter.create(BeautyV4Filter())
            .addSticker(TextSticker().apply {
                setText(TextSticker.Text("HWVC", 56f).apply {
                    x = 0.8f
                    y = 0.03f
                })
            })
            .addSticker(ImageSticker().apply {
                setImage(ImageSticker.Image().apply {
                    x = 0.03f
                    y = 0.03f
                    scale = 1.6f
                    bitmap = BitmapFactory.decodeResource(resources, R.mipmap.ic_logo_hwvc)
                })
            })

    override fun onDestroy() {
        super.onDestroy()
        mRecorder.release()
    }
}

Join the HWVC community

Please use our issues page to let us know of any problems.

License

HWVC(HardwareVideoCodec) is GPL-licensed.

hardwarevideocodec's People

Contributors

aliminabc avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.