8000 Allow optional aspect ratio handling in RTCVideoView · Issue #1835 · flutter-webrtc/flutter-webrtc · GitHub
[go: up one dir, main page]

Skip to content

Allow optional aspect ratio handling in RTCVideoView #1835

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

Open
ygalbrami opened this issue May 10, 2025 · 0 comments
Open

Allow optional aspect ratio handling in RTCVideoView #1835

ygalbrami opened this issue May 10, 2025 · 0 comments

Comments

@ygalbrami
Copy link

Feature Request: Optional Aspect Ratio Handling in RTCVideoView

if I use this on full screen it will zoom In and it will cut the outside video, so i have remove the aspect ratio
and starch video width and height.
as i use it for streaming my screen i create my own source.

What I Did

I modified the RTCVideoView widget to allow full-screen rendering without being constrained by the video's aspect ratio. The original implementation used a SizedBox with dimensions based on the aspectRatio, which made it difficult to achieve flexible layouts like full-screen views.

In my customized version, I removed the aspect ratio logic and instead used the full available height and width from LayoutBuilder. I replaced the internal sizing logic with this:

FittedBox(
          // clipBehavior: Clip.hardEdge,
          fit: objectFit == RTCVideoViewObjectFit.RTCVideoViewObjectFitContain
              ? BoxFit.contain
              : BoxFit.fill, //change it to fill,
          child: Center(
            child: ValueListenableBuilder<RTCVideoValue>(
              valueListenable: videoRenderer,
              builder:
                  (BuildContext context, RTCVideoValue value, Widget? child) {
                return SizedBox(
                  width: constraints.maxHeight, //* value.aspectRatio,
                  height: constraints.maxHeight,
                  child: child,
                );
              },
              child: Transform(
                transform: Matrix4.identity()..rotateY(mirror ? -pi : 0.0),
                alignment: FractionalOffset.center,
                child: videoRenderer.renderVideo
                    ? Texture(
                        textureId: videoRenderer.textureId!,
                        filterQuality: filterQuality,
                      )
                    : placeholderBuilder?.call(context) ?? Container(),
              ),
            ),
          ),
        ),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0