twilio / twilio-video-ios

Programmable Video SDK by Twilio
http://twilio.com/video
Other
65 stars 22 forks source link

is there a way to make the videoView sizing similar to Snapchat? #130

Open shalem93 opened 4 years ago

shalem93 commented 4 years ago

Pretty much when setting UIView.ContentMode, .scaleAspectFit does not size the whole screen, .scaleAspectFill the camera view is too zoomed in, and .scaleToFill the camera is too stretched.

I think the videoView's aspect ratio is probably like 4:3 when I think it may need to be 16:9. Not 100 percent sure. But when I use the app Snapchat, or apples generic camera the camera is sized for the whole screen at a reasonable zoom. I would like to recreate that camera view. Can someone please help me with this?

I am running the demo app on my iPhone 7 - iOS 14.0.1 , Xcode version 12.0.1

This is all taking place in the main LobbyViewController. I would simply like the camera to take up the full screen while being zoomed and sized correctly. Please help. The current videoView is not sized to my liking.

piyushtank commented 4 years ago

@shalem93 - The aspect ratio is set to 4:3 because, the capturer is configured to deliver 4:3 video frames. If you wish to use full screen on iPhone with 16:9 aspect ratio, you can change the VideoFormat of the capturer to 16:9 and change the VideoView to 16:9 to render the video frames.

Let me know if you have any questions.

shalem93 commented 4 years ago

IMG_6371 IMG_6372

Ok I attached two screenshots. Pretty much in the Lobbyviewcontroller I want the camera to look like the snapchat screen. Where in the demo projects code base specifically do I need to change to fix this?

In CameraConfigFactory.swift I tweak the heights and widths but its not changing the camera at all. It looks like in the config func for VideoView.swift we have three scaleTo options but scaleAspectFit is the only one that looks correct. scaleAspectFill is too zoomed. scaleToFill is too stretched. I simply want to get rid of the crop but keep the same camera zoom of scaleAspectFit.

Can you give me specific files or line numbers to fix this? Is this fixable? Do I need to do something on a xib file? I don't think the aspect ratio is the problem. The camera zoom looks correct but its specifically the cropping. How do I get rid of the cropping of the camera but keep the same zoom. So essentially we just see more of the camera being used.

Sorry for taking a week to get back to you. I will be more active going forward.

shalem93 commented 4 years ago

@piyushtank I see it is located in CameraConfigFactory.swift but im having trouble. I don't know if there is a VideoFormat you guys have that allows for full screen camera at the proper zoom im looking for. Do you have any ideas?

.scaleAspectFill is too zoomed of a camera.

Starting on line 76 of CameraConfigFactory.swift ------ // Cropping might be used if there is not an exact match for format in supportedFormats { guard format.pixelFormat == .formatYUV420BiPlanarFullRange && format.dimensions.width >= targetSize.width && format.dimensions.height >= targetSize.height else { continue }

        return format
    }

None of the formats in this array use full screen dimensions. This worries me... Please help.

shalem93 commented 4 years ago

I did not mean to close for the record. I accidentally selected that.

piyushtank commented 3 years ago

@shalem93 Apologies for not following up on this earlier. Were you able to solve the problem? Assigning the correct VideoFormat is the solution for the use case.