Code Monkey home page Code Monkey logo

cameramediacodec's Introduction

cameraMediaCodec

On Android platform, use MediaCodec to encode camera preview data and decode it to surface after that.

For now, encoder part(capture+encoder+preview) is OK, decoder part(decoder+render) is OK. The test tool is the first step of a real-time video application, like "Skype".

The data flow of encoder part is like that: get yuv data from camera preview callback, restore it into a queue(FIFO). In another thread, call QueueInputBuffer to handle the queue and call DequeueOutputBuffer to get Avc buffer. The process speed of DequeueOutputBuffer is related with QueueInputBuffer, vise versa. If QueueInputBuffer is slow, DequeueOutputBuffer will be slow. The data flow of decoder part is: in a thread, parsing the AVC buffer. If SPS/PPS found, restart the decoder. If not, call QueueInputBuffer to take away AVC buffer, and also call DequeueOutputBuffer to get raw video data.

For decoder part, need parse SPS/PPS ahead before calling configure, because we have to set "csd-0" and "csd-1" explicitly. Currently I call configure every time SPS/PPS with different picture size happens.

Make sure the preview callback return ASAP, for a high FPS. So don't handle input buffer directly in preview callback. Make sure there is only one time buffer copy from camera to encoder.

There are two main features for a realtime application:

  1. requested key frame
  2. width/height/fps/bitrate config on the fly Both support nearly perfect

New feature, but under testing:

  1. support SVC encoder

cameramediacodec's People

Contributors

ridgeback1982 avatar

Watchers

James Cloos avatar Jorstin Chan 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.