Rotate and append videos with mp4parser - android

I would like to append several video files from the camera through mp4parser.
Unfortunately, in the same fragment, despite the fact that I try to change the OrientationHint of the media recorder when changing camera, only the first one seems to work (ie. if I start with the front camera, the videos with the back camera are reversed and vice versa).
To solve this problem, I tried to rotate the video that are in the wrong direction and that works (with the method of setMatrix mp4parser, the new files are in good direction). But when I want to append the files, (all in the right direction) I get the same result as if I had not rotated the videos, as if it could have only one orientation videos for my final component video.
Do you have a solution for this?
Thanks

Related

Background video recorder with wrong camera orientation

I used code from here. But there is one problem, I can´t change camera orientation. Final video is upside down.
I tried to change it by this (I tried all possible values - 0,90,180,270):
camera.setDisplayOrientation(90);
camera.getParameters().setRotation(90);
or
camera.getParameters().set("orientation", "portrait");
camera.getParameters().set("rotation", 90);
But nothing works. Any idea how to setup it?
I tested it on Nexus 5X with Android 7.1.1.
I want to use fixed orientation, no matter how I hold device, orientation must remain same.
camera.setDisplayOrientation(90) This affects the preview frames and the picture displayed after snapshot. This does not affect the order of byte array passed in onPreviewFrame, JPEG pictures, or recorded videos. So you can't change the REC orientation using this API. If you want to change the REC orientation, you should rotate the every frame date in onPreviewFrame or rotate the SurfaceTexture base on the way you record video.
use mediaRecorder.setOrientationHint(180);

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)

Front facing Camera Recorded video not proper

I want to record Video using front facing camera. Using the example from here as reference. I changed the getCamerainstance method to getFrontFacingCamera. I am able to see the preview while recording. But when i close the recording and play the video, it is always some horizontal flickering lines. Seems like some encoding issue. I tried- changing the media recorder profile to QUALITY_LOW/ QUALITY_HIGH, - Setting the frame rate to 15. the same app works perfectly when i use rear camera.
P.S: I have set the preview's(surface view's) size to 208×208. (Should this affect? , It's working fine with rear camera).
Thanks
Finally solved it. (In case someone faces the same issue)
need to use: mediaRecorder.setVideoSize(320,240);

Android - VideoView shows thumbnail of previous video

I made a video player based on VideoView widget. The videos are loaded from internet.
Everything works fine, except one little thing.
I open a video, and while it is playing I click the "Next" button to advance to the next video. And the issue is that while the next video is loading, it shows me the thumbnail of previous video.
I would like to not display any thumbnail, or at least the thumbnail of currently loading video, but deffinetly NOT the thumbnail of previous video.
So, is there a method like "flush()", or something like this to clear the videovideo and not show the thumbn. of previous video? Or at least why does it happen?
To get rid off that thumbnail, it was necessary to re-creating the VideoView when clicking Next/Prev buttons. Maybe not one of the best solution, but at least it solved the issue.

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