ChillingVan/AndroidInstantVideo
ChillingVan/AndroidInstantVideo has 721 GitHub stars and 200 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-09 04:17 UTC. Last push 2022-12-18.
展现Android硬编码下的视频数据流动,可以对视频做处理,例如加滤镜,加水印等,做直播推流(用RTMP)。 Show the stream of Android video hardware encode, including video processing and video publishing by RTMP.
Measured star growth
- in 24h
- 0
- in 7 days
- Update delayed
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README_EN.md
OriginalAndroidInstantVideo
Show the stream of Android video hardware encode, including video processing and video publishing.
- Use MediaCodec for H264 encoding.
- Use MediaCodec for AAC encoding.
- Use RTMP for video publishing.
Thanks for these projects
Requirement
- Android API >= 18
Feature
MediaCodec Hardware encoding for H264 + Video Processing
Sample: TestVideoEncoder The Video Processing Part:
public class TestVideoEncoder {
//...
public void prepareEncoder() {
//...
h264Encoder.setOnDrawListener(new H264Encoder.OnDrawListener() {
@Override
public void onGLDraw(ICanvasGL canvasGL, SurfaceTexture producedSurfaceTexture, RawTexture rawTexture, @Nullable SurfaceTexture outsideSurfaceTexture, @Nullable BasicTexture outsideTexture) {
// 此处可以使用canvasGL的drawTexture, drawBitmap等方法实现对视频帧的处理.
//
//
}
});
//...
}
//...
}
The key for video frame processing : android-opengl-canvas
H264 test file: /storage/sdcard/Android/data/com.chillingvan.instantvideo.sample/files/test_h264_encode.h264,可以在代码里修改输出路径
public class TestVideoEncoder {
public TestVideoEncoder(Context ctx, final EglContextWrapper eglCtx) {
try {
os = new FileOutputStream(ctx.getExternalFilesDir(null) + File.separator + "test_h264_encode.h264");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
You can use PotPlayer to play the test files.
Camera
I wrap a class for simple usage InstantVideoCamera Not work well at my 4.4 phone but fine on my 6.0 phone.
AAC Audio
Sample: TestAudioEncoder
Test file directory:/storage/sdcard/Android/data/com.chillingvan.instantvideo.sample/files/test_aac_encode.aac",可以在代码里修改输出路径 You can use PotPlayer to play the test files.
LibRtmp for RTMP Stream
Use nginx-rtmp-module for your Nginx test local server. Use OBS for comparing effect. And player can be VLC,PotPlayer,ffplay. Make sure you use player open stream first because of the simple test server.
Sample: TestCameraPublisherActivity
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);
}
...
}
Latest Update:
- Add Mp4Muxer(Use Android MediaMuxer). Sample: TestMp4MuxerActivity
- Update Interface Imuxer. Add more parameters to StreamPublisherParam.
TODO
- RTSP Stream.
Pull Request
Welcome. Please add sample code to sample module. Add your license comment.
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.
Explore related projects
ytdl-org/youtube-dl
Command-line program to download videos from YouTube.com and other video sites
141,500 starsexcalidraw/excalidraw
Virtual whiteboard for sketching hand-drawn like diagrams
135,331 starsgodotengine/godot
Godot Engine – Multi-platform 2D and 3D game engine
119,840 starsmrdoob/three.js
JavaScript 3D Library.
117,905 stars