Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ApiVideoCameraPreview is automatically resized to a strange ratio #75

Open
1 of 2 tasks
dunghacknicktao opened this issue Oct 30, 2024 · 5 comments
Open
1 of 2 tasks
Labels
bug Something isn't working

Comments

@dunghacknicktao
Copy link

Version

v1.2.0

Which operating systems have you used?

  • Android
  • iOS

Environment that reproduces the issue

Iphone XR OS14

Is it reproducible in the example application?

Not tested

RTMP Server

n/a

Reproduction steps

Hello,
Currently, I have a problem related to the CameraPreview, after a short time starting to stream to the RTMP server, the camera preview widget flashes the screen, and then the frame ratio changes (seems to be 16:9)
I don't encounter this on Android devices
Please help me troubleshoot this problem!

original-D373FC2B-1A24-484A-A89F-4CF044E2B815.mp4

Expected result

normal camera ratio

Actual result

strange ratio

Additional context

Preview widget:
image

The parent widget:
image

Relevant logs output

No response

@dunghacknicktao dunghacknicktao added the bug Something isn't working label Oct 30, 2024
@ThibaultBee
Copy link
Member

Hi,

Could you try to reproduce on the example or provide a code snippet?
It kind of look likes the widget has detected on orientation changed.

@dunghacknicktao
Copy link
Author

Hi,

Could you try to reproduce on the example or provide a code snippet? It kind of look likes the widget has detected on orientation changed.

I can't test the example because has errors :( . The log when I try to run the example in my device:
Running pod install...
Running Xcode build...
Xcode build done. 33.5s
Failed to build iOS app
Could not build the precompiled application for the device.
Swift Compiler Error (Xcode): Expected 'var' keyword in static property declaration
/Users/mac/Documents/PROJECT/webrtc/api.video-flutter-live-stream-main/example/ios/Pods/HaishinKit/Sources/RTMP/AMFFoundation.swift:36:22

Swift Compiler Error (Xcode): Consecutive declarations on a line must be separated by ';'
/Users/mac/Documents/PROJECT/webrtc/api.video-flutter-live-stream-main/example/ios/Pods/HaishinKit/Sources/RTMP/AMFFoundation.swift:36:30

Swift Compiler Error (Xcode): Type annotation missing in pattern
/Users/mac/Documents/PROJECT/webrtc/api.video-flutter-live-stream-main/example/ios/Pods/HaishinKit/Sources/RTMP/AMFFoundation.swift:36:23

Swift Compiler Error (Xcode): 'nonisolated' can not be applied to stored properties
/Users/mac/Documents/PROJECT/webrtc/api.video-flutter-live-stream-main/example/ios/Pods/HaishinKit/Sources/RTMP/AMFFoundation.swift:36:11

Swift Compiler Error (Xcode): Expected 'var' keyword in static property declaration
/Users/mac/Documents/PROJECT/webrtc/api.video-flutter-live-stream-main/example/ios/Pods/HaishinKit/Sources/RTMP/RTMPSharedObject.swift:82:30

Swift Compiler Error (Xcode): Consecutive declarations on a line must be separated by ';'
/Users/mac/Documents/PROJECT/webrtc/api.video-flutter-live-stream-main/example/ios/Pods/HaishinKit/Sources/RTMP/RTMPSharedObject.swift:82:38

Swift Compiler Error (Xcode): Type annotation missing in pattern
/Users/mac/Documents/PROJECT/webrtc/api.video-flutter-live-stream-main/example/ios/Pods/HaishinKit/Sources/RTMP/RTMPSharedObject.swift:82:31

Swift Compiler Error (Xcode): 'nonisolated' can not be applied to stored properties
/Users/mac/Documents/PROJECT/webrtc/api.video-flutter-live-stream-main/example/ios/Pods/HaishinKit/Sources/RTMP/RTMPSharedObject.swift:82:19

Uncategorized (Xcode): Command SwiftCompile failed with a nonzero exit code

Error launching application on Phôn.

@dunghacknicktao
Copy link
Author

The log when I run in my project:
[GETX] GOING TO ROUTE /stream
[GETX] Instance "StreamRepository" has been created with tag "StreamRepository"
[GETX] Instance "StreamController" has been created
[GETX] Instance "StreamController" has been initialized
flutter: 💚️ INFO: --STREAM: socket ip https://blabla.vn:2114
flutter: connect to https://blabla.vn:2114
2024-05-11 10:11:17.797 [Info] [com.haishinkit.HaishinKit] [IOAudioResampler.swift:227] setUp(_:) > inputFormat:<AVAudioFormat 0x283a9b020: 1 ch, 48000 Hz, Int16>,outputFormat:<AVAudioFormat 0x283a991d0: 1 ch, 48000 Hz, Int16>
2024-05-11 10:11:17.825 [Info] [com.haishinkit.HaishinKit] [AudioCodec.swift:149] makeAudioConverter() > inputFormat:<AVAudioFormat 0x283a991d0: 1 ch, 48000 Hz, Int16>,outputFormat:<AVAudioFormat 0x283a99ef0: 1 ch, 48000 Hz, aac (0x00000002) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame>
flutter: 💚️ INFO: --STREAM: emitJoinStartStreamEvent rtmpApiSecret - 314593
flutter: send: initRTMP - {apiSecret: rtmpApiSecret, userId: 6715d233b74fb1004a100f02, eventId: 314593}
flutter: connected
flutter: onOpen
flutter: {name: Phon(ios), user_agent: flutter-webrtc/ios-plugin 0.0.1}
flutter: 💚️ INFO: --STREAM: nhan START_STREAM_EVENT
flutter: 💚️ INFO: {rtmp: rtmp://blabla.vn:2117/blabla/db759172-0555-4179-9ca6-c67babaac26f?sign=1730862678-a07c0275b34442066dff9186e3dda476, rtmpStreamKey: db759172-0555-4179-9ca6-c67babaac26f}
flutter: Received data: stream-ok - {rtmp: rtmp://blabla.vn:2117/blabla/db759172-0555-4179-9ca6-c67babaac26f?sign=1730862678-a07c0275b34442066dff9186e3dda476, rtmpStreamKey: db759172-0555-4179-9ca6-c67babaac26f}
flutter: 💚️ INFO: --STREAM: co READY_STREAM_EVENT
flutter: 💚️ INFO: {rtmp: rtmp://blabla.vn:2117/blabla/db759172-0555-4179-9ca6-c67babaac26f?sign=1730862678-a07c0275b34442066dff9186e3dda476, rtmpStreamKey: db759172-0555-4179-9ca6-c67babaac26f}
flutter: --STREAM: startVideoStreaming rtmp://blabla.vn:2117/blabla/db759172-0555-4179-9ca6-c67babaac26f?sign=1730862678-a07c0275b34442066dff9186e3dda476 - key db759172-0555-4179-9ca6-c67babaac26f
flutter: --STREAM: startVideoSt 999
flutter: 💚️ INFO: URL CONVERT
flutter: 💚️ INFO: rtmp://blabla.vn:2117/blabla/
flutter: 💚️ INFO: db759172-0555-4179-9ca6-c67babaac26f
flutter: 💚️ INFO: rtmp://blabla.vn:2117/blabla/db759172-0555-4179-9ca6-c67babaac26f?sign=1730862678-a07c0275b34442066dff9186e3dda476

2024-05-11 10:11:44.890 [Info] [com.haishinkit.HaishinKit] [RTMPNWSocket.swift:168] stateDidChange(to:) > Connection is ready.
2024-05-11 10:11:44.896 [Info] [com.haishinkit.HaishinKit] [RTMPNWSocket.swift:159] viabilityDidChange(to:) > Connection viability changed to true
flutter: Connection succeeded

!!! Please note that at the time log [com.haishinkit.HaishinKit] is generated, the image will be distorted
2024-05-11 10:11:44.890 [Info] [com.haishinkit.HaishinKit] [RTMPNWSocket.swift:168] stateDidChange(to:) > Connection is ready.
2024-05-11 10:11:44.896 [Info] [com.haishinkit.HaishinKit] [RTMPNWSocket.swift:159] viabilityDidChange(to:) > Connection viability changed to true
flutter: Connection succeeded

@dunghacknicktao
Copy link
Author

Hello,
The new update is that I tried version 1.1.3 and set the widget's size manually; the ratio did not change strangely (from portrait to landscape as in version 1.2.0 above).
My device: Iphone XR (OS 14) and iPhone 13 Promax (OS18)
Hope my findings will help you solve the scaling error described above!
Thanks

@aniketcme
Copy link

aniketcme commented Nov 11, 2024

i have try using passing height and width in AppVideoCamraPerview from outside Get.size.height and width it work for me but i cannot creat build becouse of changes in AppVideoCamraPerview

const ApiVideoCameraPreview(
{super.key,
required this.controller,
required this.height,
required this.width,
this.fit = BoxFit.contain,
this.child});

    double _aspectRatio = 16.9;

Size _size = const Size(Widget.width, Widget.height);

ApiVideoCameraPreview(controller: controller.apiVideoLiveStreamController!,fit: BoxFit.fitHeight,height:
Get.size.height,width: Get.size.width,),

please update your code and release new viersion

and in ios on controller init it taking 1 or 2 minit for initialize it freaze screen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants