ChillingVan / AndroidInstantVideo

展现Android硬编码下的视频数据流动,可以对视频做处理,例如加滤镜,加水印等,做直播推流(用RTMP)。 Show the stream of Android video hardware encode, including video processing and video publishing by RTMP.
Apache License 2.0
718 stars 196 forks source link

How to draw list of videos over camera preview and record simultaneously? #9

Closed sumitatcs closed 6 years ago

sumitatcs commented 6 years ago

I have seen the TestMp4MuxerActivity and can draw images over camera preview. How do i draw video over camera preview? I want to achieve real time video filters(like stars and all) like other photo editing apps. For this i want to draw the filter videos over camera preview and record it simultaneously. I am able to decode a video to another surface but not able to draw it on the camera preview itself. How to achieve this?

ChillingVan commented 6 years ago

You can check the example MultiTextureActivity or MergeVideoActivity in https://github.com/ChillingVan/android-openGL-canvas I have added feature last week.

sumitatcs commented 6 years ago

I checked those examples but I have not been able to figure out how to simultaneously record using the encoder. How do i proceed to integrate the encoder with multitexture?

ChillingVan commented 6 years ago

@sumitatcs Your encoder can provide a Surface right? Then you can pass the surface to MultiTexOffScreenCanvas. And when MultiTexOffScreenCanvas draws, what it draws will output to encoder then the encoder can produce video frames.

Unfortunally, this AndroidInstantVideo lib has not integrated the MultiTexOffScreenCanvas. You can wait or DIY. Maybe tomorrow I will integrate it.

ChillingVan commented 6 years ago

I have added the example of Multi Texture. Check the TestMp4MuxerActivity

inventionsbyhamid commented 6 years ago

I am trying to do something similar but with a list of videos. I am encountering android.media.MediaCodec$CodecException: Error 0xffffffde. What I did was set InitialTextureCount for CameraPreviewTextureView to videoList size + 1, similarly for streampublisher, creating list of mediaplayerhelpers and surfaces for videos and putting the corresponding play/stop events for all of the mediaplayerhelpers in activity callbacks like in example. What I am not sure is when to call addProducedGLTexture to add textures for multiple videos.

ChillingVan commented 6 years ago

@inventionsbyhamid I think you need not to call addProducedGLTexture since you have set initial count and your media list size is fixed. You should be able to get the producedTexture through surfaceCreatedListener. Does the MultiTex sample work? If it works, you can add more media player and add initialCount. If it works, you may be able to find why yours does not work.

Or you can upload your demo code here.