Code Monkey home page Code Monkey logo

Comments (7)

wang-bin avatar wang-bin commented on June 11, 2024
return Container(
      width: double.infinity,
      height: double.infinity,
      color: Colors.transparent,
      child: _controller.value.isInitialized ? AspectRatio(aspectRatio: _controller.value.aspectRatio, child: VideoPlayer(_controller)) : Container(),
    );

What does it mean?

from fvp.

lKinderBueno avatar lKinderBueno commented on June 11, 2024
return Container(
      width: double.infinity,
      height: double.infinity,
      color: Colors.transparent,
      child: _controller.value.isInitialized ? AspectRatio(aspectRatio: _controller.value.aspectRatio, child: VideoPlayer(_controller)) : Container(),
    );

What does it mean?

The code was not fully representative of the problem. I have updated the first post with a better code and more details

from fvp.

wang-bin avatar wang-bin commented on June 11, 2024

the video aspect ratio is not 5/4, but 5/4*1.45455 = 1.82, 1.45455 is pixel aspect ratio, i.e. a pixel width/height is not 1. the original video aspect ratio is correct in fvp, android official player is wrong, you can compare with other players, for example mpv. The official player supports macOS now, so you can also compare the results with and without fvp on macOS.

from fvp.

lKinderBueno avatar lKinderBueno commented on June 11, 2024

the video aspect ratio is not 5/4, but 5/4*1.45455 = 1.82, 1.45455 is pixel aspect ratio, i.e. a pixel width/height is not 1. the original video aspect ratio is correct in fvp, android official player is wrong, you can compare with other players, for example mpv. The official player supports macOS now, so you can also compare the results with and without fvp on macOS.

The issue at hand is not 100% about the original aspect ratio of the video, but more related to a custom aspect ratio due to what appears to be transparent bars at the top and bottom of videos played with FVP.

The player is intended for use in a scenario where my users may want to play videos with varying aspect ratios, but this becomes problematic as FVP interprets the transparent bars as part of the video content.
The sample video, originally in a 16:9 aspect ratio, has been stretched to some other non-standard aspect ratio to simulate this scenario.

It happens also if I use the backend api:

import 'package:flutter/material.dart';
import 'package:fvp/mdk.dart';
import 'package:fvp/fvp.dart';
import 'package:logging/logging.dart';


void main() {
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((record) {
    print('${record.loggerName}: ${record.message}');
  });
  registerWith();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: VideoPlayerScreen(),
      ),
    );
  }
}

class VideoPlayerScreen extends StatefulWidget {
  VideoPlayerScreen();

  @override
  _VideoPlayerScreenState createState() => _VideoPlayerScreenState();
}

class _VideoPlayerScreenState extends State<VideoPlayerScreen> {
  late final player = Player();

  @override
  void initState() {
    super.initState();
    player.media = 'https://supertest.netsons.org/output.mp4';
    player.loop = -1;
    player.state = PlaybackState.playing;
    player.setAspectRatio(16/9);
   

    player.updateTexture();
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: ValueListenableBuilder<int?>(
        valueListenable: player.textureId,
        builder: (context, id, _) => id == null ? const SizedBox.shrink() : Texture(textureId: id),
      ),
    );
  }


  @override
  void dispose() {
    super.dispose();
    player.dispose();
  }
}

from fvp.

wang-bin avatar wang-bin commented on June 11, 2024

Now I know the reason. I use a texture in video frame size, but render the content to texture in another aspect ratio.

from fvp.

wang-bin avatar wang-bin commented on June 11, 2024

try the latest code. upgrading mdk is required

from fvp.

lKinderBueno avatar lKinderBueno commented on June 11, 2024

try the latest code. upgrading mdk is required

Tested and it is working. Thank you!

from fvp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.