pinkfish / flutter_rtmppublisher

Publisher to rtmp using the camera plugin as a basis to do all the basic camera/record management.
BSD 3-Clause "New" or "Revised" License
95 stars 121 forks source link

IOS Orientation #24

Open hulohot opened 3 years ago

hulohot commented 3 years ago

Hi! I am running your demo app on a physical IPhone and am not able to get the RTMP stream to switch from portrait to landscape. I really just need the stream to in landscape.

Not sure if this is a bug or intended.

sbruler commented 3 years ago

Getting the same issue here. Tried manually setting up orientation switching through the HaishinKit and had no luck.

pinkfish commented 3 years ago

Weird I did get it to switch. It sticks on one orientation once you start though

On Tue, Aug 4, 2020, 4:07 PM sbruler notifications@github.com wrote:

Getting the same issue here. Tried manually setting up orientation switching through the HaishinKit and had no luck.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pinkfish/flutter_rtmppublisher/issues/24#issuecomment-668870184, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATOMMJLZJA47P3XFGXGLFLR7CIEFANCNFSM4PK7TQZQ .

sbruler commented 3 years ago

Weird I did get it to switch. It sticks on one orientation once you start though

Thanks for the reply. Can you share how you configured it? Maybe I'm approaching it incorrectly.

hulohot commented 3 years ago

I was able to get the web player to force portrait mode by setting these values in the FlutterRTMPStreaming.swift file.

@objc
    public func addVideoData(buffer: CMSampleBuffer) {
        if let description = CMSampleBufferGetFormatDescription(buffer) {
            let dimensions = CMVideoFormatDescriptionGetDimensions(description)
            rtmpStream.orientation = .landscapeLeft
            rtmpStream.videoSettings = [
                .width: 1920,
                .height: 1080,
                .profileLevel: kVTProfileLevel_H264_Baseline_AutoLevel,
                .maxKeyFrameIntervalDuration: 2,
                .bitrate: 1200 * 1024
            ]
            rtmpStream.captureSettings = [
                .fps: 24
            ]
        }
        rtmpStream.appendSampleBuffer( buffer, withType: .video)
    }
 

But I was not able to get the actual IOS camera to rotate to landscape mode, it is stuck in portrait and the end result is a cropped view of the landscape camera preview.

This is a (rotation) locked view. IMG_3271

This is a (rotation) free view. IMG_3272

This is the end result in both cases, even after restarting the app and starting in either orientation.

Screen Shot 2020-08-10 at 5 03 45 PM

Any help from either of you with this issue would be greatly appreciated.

burtonmiller commented 3 years ago

This issue is pretty serious for me. I've been trying to debug the code myself, but previewQuarterTurns is often null (maybe always?) and doesn't affect preview rotation on iOS anyway. Android seems to work fine.

Glad to chip in a few bucks to get this prioritized:)

burtonmiller commented 3 years ago

Part of the problem is in RtmppublisherPlugin.m (ios code):

connection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft; //AVCaptureVideoOrientationPortrait;

i swapped in a hard-coded landscape value for the AV capture, but now both the preview and broadcast dimensions are screwed up.

hulohot commented 3 years ago

@burtonmiller Just wanted to check in and see if you ever found a solution for this?

sbruler commented 3 years ago

Take it nothing has changed here?

russellmiddleton commented 2 years ago

Anyone found the solution or workaround for this issue? (iOS RTMP stream always in portrait mode, android works fine).