AndroidInstantVideo

展现Android硬编码下的视频数据流动,可以对视频做处理,例如加滤镜,加水印等。

本项目主要是为了展现Android使用硬编码下的视频数据流动,目前完成了H264和AAC编码以及对视频帧的图像处理,以及RTMP直播推流。欢迎Fork和Pull Request。

English README

感谢以下项目 LibRtmp-Client-for-Android

使用要求

用法

功能:

对于生成的文件,可以在PC上使用 PotPlayer 播放

public class TestCameraPublisherActivity extends AppCompatActivity { ...

@Override
protected void onCreate(Bundle savedInstanceState) {
    ...
    handler = new Handler(handlerThread.getLooper()) {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            StreamPublisher.StreamPublisherParam streamPublisherParam = new StreamPublisher.StreamPublisherParam();
            streamPublisher.prepareEncoder(streamPublisherParam, new H264Encoder.OnDrawListener() {
                @Override
                public void onGLDraw(ICanvasGL canvasGL, SurfaceTexture surfaceTexture, RawTexture rawTexture, @Nullable SurfaceTexture outsideSurfaceTexture, @Nullable BasicTexture outsideTexture) {

                    // Here you can do video process
                    // 此处可以视频处理,例如加水印等等
                    canvasGL.drawSurfaceTexture(outsideTexture, outsideSurfaceTexture, 0, 0, outsideTexture.getWidth(), outsideTexture.getHeight());
                    Loggers.i("DEBUG", "gl draw");
                }
            });
            try {
                streamPublisher.startPublish(addrEditText.getText().toString(), streamPublisherParam.width, streamPublisherParam.height);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };

// streamPublisher = new CameraStreamPublisher(new RTMPStreamMuxer(), cameraPreviewTextureView, instantVideoCamera); String filename = getExternalFilesDir(null) + "/test_flv_encode.flv"; streamPublisher = new CameraStreamPublisher(new RTMPStreamMuxer(filename), cameraPreviewTextureView, instantVideoCamera); } ... }



### 最近更新
1. 添加使用Android MediaMuxer的 Mp4Muxer,输出Mp4文件。例子 TestMp4MuxerActivity
2. 修改 IMuxer 接口,使之更通用。给StreamPublisherParam添加更多参数。

### TODO

1. RTSP流

### 关于 Pull Request

欢迎Fork!
添加了功能发出 Pull Request 的话,希望能在sample的module里添加相应的测试代码,最好在文件开头加上自己的license注释。

### 相关博文

[使用MediaCodec和RTMP做直播推流](http://www.jianshu.com/p/3c479c0f4876)

## License
    Copyright 2017 ChillingVan.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.