同步操作将从 ChillingVan/AndroidInstantVideo 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Show the stream of Android video hardware encode, including video processing and video publishing.
Thanks for these projects
sample:
// in root build.gradle
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
// module build.gradle
dependencies {
compile 'com.github.ChillingVan:AndroidInstantVideo:v1.0.1.0'
}
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);
}
...
}
Android Default Muxer. Please implement IMuxer
RTSP Stream.
Welcome. Please add sample code to sample module. Add your license comment.
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.
Thanks for your support !!! alipay wechat pay
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。