Android playing video with the camera surfaceview in background - android

Hello
i have a surfaceview and a videview in a framlayout. if i start the video in oncreate, i see all perfectly, the video playing while the camera plays in background.
but if i start the video after oncreate, for example in onpreviewframe, i can only hear the video, but it's like behind the camera, and all i see is the camera view.
any help?

You Need to Merge both layouts... see the Example.

Related

how to save camera preview frame in video?

I am trying to add a green frame when record a video using android camera like the image below.
I build a custom cameraPreview and apply preview.setForeground(getDrawable(R.drawable.frame_green)); in the Camera Activity
After recording a video, this green frame won't show in the video.
You cannot use MediaRecorder to save a video with modified camera stream. You can use MediaCodec to encode modified video (see CameraToMpegTest sample at http://bigflake.com/mediacodec).
Or you can post-process the video file, as suggested by H.Brooks in comments above.

How to flip(mirror effect) a video in a VideoView?

I know there are ways using TextureViews and some other ways, but can we do a video flip in a VideoView, I tried using the method scaleType of X axis to -1, but just getting a black screen. Is there no way to do a simple video flip for a video being played in a videoview? Am I forced to use a TextureView or other methods?
As you said, the best option is to use TextureView... Android's VideoView can only play videos straight and not mirrored.
If you want your app to play a video mirrored (for instance if the video was recorded using a front camera), you will need to use a TextureView, which can be easily mirrored by specifying android:scaleX=-1 in the XML file, or textureView.setScaleX(-1) in the code. (source)

Stop the video on last frame

I am using VideoView to play a video and have some difficulties to stop it and keep the last frame after video finishes playing. Currently I am stuck with black last frame after video ends.
Is there a way to accomplish that? Thank you.
To get the last frame of a video you can skip to its end by using:
video.seekTo(video.getDuration());

No video, only sound with VideoView

When I play a video file using a VideoView on Android, I can hear the sound fine, but the video does not show.
So, when I use :
myVideoView.setZOrderOnTop(true);
then the video shows fine, however, then my TextView is behind the VideoView and I need it to be in front.
Therefore, I either need a solution so that the video is played without using setZOrderOnTop, or I need a way to get the text in front of the video while using setZOrderOnTop.
videoView.setBackgroundColor(Color.TRANSPARENT);

How can I show a preview picture after taking a video using MediaRecorder?

I am using MediaRecorder and a SurfaceView to create a custom video camera app. After the user has clicked a stop button, I'd like to show the user a preview of the video (maybe the first or last frame). Is there an easy way to do this?
Thanks!
for future references. It's possible to use the
surfaceHolder.getSurface().freeze();
to hold the last frame.

Categories

Resources