wang-bin / fvp

Flutter video player plugin for all desktop+mobile platforms. download prebuilt examples from github actions. https://pub.dev/packages/fvp
BSD 3-Clause "New" or "Revised" License
197 stars 31 forks source link

Hardware decoder forces 16:9 #167

Closed azukaar closed 1 month ago

azukaar commented 1 month ago

When playing a different aspect ratio on Android with hardware decoder (does not happen in software I think) the aspect ratio seems to be forced to be 16:9 The result for a 4:3 video is a texture that has a 16:9 aspect ratio, with black bars on the side. Then the player itself will add back bar on the top/bottom to match the screen size (if the screen is not 16:9). Here's an example:

image

wang-bin commented 1 month ago

any log?

azukaar commented 1 month ago

Logs here: https://pastebin.com/7FKTFcuB

And code for displaying the texture:


  Future<void> _getTextureSize() async {
    final videoPlayerPlatform =
        VideoPlayerPlatform.instance as MdkVideoPlayerPlatform;
    if (widget.player != null) {
      final size = await widget.player.textureSize;
      if (size != null && mounted) {
        setState(() {
          _textureSize = size;
        });
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    if (_textureSize == null) {
      return const Center(child: CircularProgressIndicator());
    }

    return AspectRatio(
      aspectRatio: _textureSize!.width / _textureSize!.height,
      child: Texture(
        textureId: widget.player.textureId.value ?? 0,
      ),
    );
  }
wang-bin commented 1 month ago

the video size is 1928*1080, so 16:9. why do you think it should be 4:3 ?

azukaar commented 1 month ago

Sorry I mis-interpreted the data, I thought the decoder was adding the border, closing now