Giter Club home page Giter Club logo

testmediacodec's Introduction

[TOC]

说明

用kotlin编写的java层音视频解码Demo代码

将测试用的mp4文件放置在SD的Download/test.mp4下

  • MediaExtractor
  • MediaCodec
  • 权限
  • SurfaceView
  • 弱引用
  • kotlin特性:数组声明;null处理;object;data class;SAM;when;for in until

视频解码

  1. MediaExtractor设置数据源
  2. 获取特定的track的Id
  3. 获取此track的信息(mime)
  4. 根据track的信息创建decoder并关联播放的surface
  5. decoder开始
  6. 从decoder获取一个输入缓冲的索引
  7. 从extractor获取一段视频缓冲数据
  8. 将缓冲数据放入输入索引指向的缓冲区
  9. decoder获取一段待处理的输出缓冲
  10. 同步延迟
  11. 将输出的流媒体数据渲染到Surface上
  12. 停止解码,释放资源

音频解码

与视频差不多,差异的地方:

  • 根据track信息构建audioTrack并开始播放
  • 从解码器的输出Buffer中获取PCM流媒体数据,写入到audioTrack中

参考: Android MediaExtractor + MediaCodec 实现简易播放器

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.