I am using Vitamio media player to play RTMP stream onto a SurfaceView, everything is fine but the video size is smaller than the screen. I am looking for a way to scale the video to fit the entire screen. I set the SurfaceHolder to the fixed size of my Nexus4 display (1280*720) and the video received is (950*640).
I tried overriding onDraw but no results.
I am trying now to override unlockCanvasAndPost function of SurfaceHolder, so I can scale the canvas, but don't know exactly how to achieve this.
Also, maybe there are related AVoptions I can pass to the player?
You can scale the video surface, VitamioDemo have a sample, https://github.com/yixia/VitamioBundle/blob/master/vitamio-sample/src/io/vov/vitamio/demo/VideoViewSubtitle.java
Related
I have this problem which honestly I don't know how to solve, I'm using a SurfaceView to render content. The video is a letterbox type video where margins needs to be chopped of from the video in order to make it fill the screen and be in correct aspect ratio.
I have tried 3 different things till now:
Put the SurfaceView in the center of an over-sized FrameView (this worked but on some devices it caused video artefacts)
Use a TextureView and a matrix to scale, this works but on some devices I'm getting a green screen or very poor performance, beside Google suggest that using SurfaceView is a better approach.
My preferred (and probably most correct) approach is to use a SurfaceView and set media codec to: VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING something like this:
#Override
public void onOutputFormatChanged(#NonNull MediaCodec mediaCodec, #NonNull MediaFormat mediaFormat) {
android.util.Log.d(TAG, "Output format changed!");
mediaCodec.setVideoScalingMode(MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
}
This does work, as expected however on some devices (which I can't reproduce on any of my tests), this happens:
https://www.youtube.com/watch?v=FFOafPVgADQ
https://www.youtube.com/watch?v=38wW_AeNnTg
The MediaCodec is created like:
MediaCodec.createDecoderByType("video/avc");
I have tried using, which seems to fix the problem, but has very poor performance (as it's done by the CPU rather then GPU)
MediaCodec.createByCodecName("OMX.google.h264.decoder");
Any idea why is that jumping happening? Am I right to think that it's a broken video driver and probably I won't be able to fix it?
I am using ExoPlayer for playing videos in my project. The problem is whatever video I tried to play the video resolution is always in 4:3 ratio only. I tried with the following code to overcome my problem. After adding the following lines the video seems to be completely stretched.
mExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
exoPlayer.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
What you want to use is:
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_ZOOM);
This code fit's the video to the view size but maintains it's aspect ratio by cropping from the sides.
On exoplayer, I want to force scaling for media source in 720*576.
For the moment, these video is displayed in 4:3, and I want to force display in 16:9.
Is there a way to do that?
Self answer, the correct response was :
simpleExoPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
And
player.setVideoScalingMode(C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
Now display is fine, even if my source is in 4:3 ratio.
I'm trying to use a VideoPlayer component, with a URL source and a RenderTexture as the target, to show a video in my Unity mobile game. The video is loaded and starts playing, however the resulting texture is only 1 color. The color does change every frame to something matching what the video would look like that frame, but it's just the 1 color. Audio is working fine. On the VideoPlayer component, the Aspect Ratio is set to "Fit Inside", but I have tried all options here with the same result. As for the RenderTexture, it's set to the same resolution as the input video, and the Color Format is set to RGB565 (which both Android and iOS should support according to SystemInfo.SupportRenderTextureFormat()). I'm all out of ideas, any help would be appreciated.
EDIT: A workaround could be using "material override" instead of rendering to a texture. This doesn't work though if you want to use the texture specifically instead of only showing the video on a material, plus the fact that Material Override doesn't support objects with multiple renderers/materials. Not really a fix, but a workaround for those who find this question before a solution has been found.
I just had this myself and fixed it.
In the Raw Image, search UV Rect and set its W and H to 1. I had changed that, which made it only sample 1 pixel.
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)