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.
Related
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.
The goal is to crop a preview on the surface for frames that come from Camera2 api capture session, but not to crop the video that will be created itself.
For example, I have a streaming resolution of 1920x1080 (16:9), and the screen size (just for instance) 2000x3000 (2:3 -> 6:9 or 16:24, lets pick the second variant for example), so I'd like to have my video in the original streaming resolution - 1920x1080, but my preview to fill all the available space without View resizing - so it should be 5333x3000 (just bumping the size up to fill the rectangle area using the same aspect ratio as the streaming resolution's one), and then to "cut" the "frame data that corresponds to this surface's resolution (which is, I suppose, 5333x2000)" to 2000x3000 (just remove (5333 - 2000) / 2 from both top and bottom).
Is it possible?
P.S.: the bad thing is that google sample for camera2 api resizes the view itself, and these "blank areas" are undesired for me. I haven't found anything that even closely matches my problem.
P.S.S.: AFAIU this SO solution crops the frame that comes from the camera itself, but I need my video to be in the original resolution.
If you're using a TextureView, you can probably adjust its transform matrix to scale up the preview (and cut off the edges in the process). Read the existing matrix, fix up the aspect ratio and scale it up, and then save the new matrix.
But please note that saving a different field of view than what you're showing to the user is probably going to get you negative reactions - please use the preview to frame what they want to record, and if what you're saving has extra stuff, the recorded video won't match expectations. Of course, maybe this isn't a concern for your use case.
I use surfaceViewRender to render my remote webRTC stream,
and I want to make the remote stream fill my device screen.
I try this code:
pipRenderer.setScalingType(ScalingType.SCALE_ASPECT_FILL);
but actually the display size would over my screen size,
I try to scale the width to fit it:
pipRenderer.setScaleX(0.8f);
but the result become more strange,
Does anybody can tell how to do this?
I want make the stream auto fit the screen size but do not over screen,
I will very appreciate to you!!
set pipRenderer.setScalingType(ScalingType.SCALE_ASPECT_FIT); instead of
pipRenderer.setScalingType(ScalingType.SCALE_ASPECT_FILL); while initializing the renderer
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 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