Closed lKinderBueno closed 8 months ago
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?
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
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 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();
}
}
Now I know the reason. I use a texture in video frame size, but render the content to texture in another aspect ratio.
try the latest code. upgrading mdk is required
try the latest code. upgrading mdk is required
Tested and it is working. Thank you!
Describe the bug fvp does not respect the original aspect ratio of some video files when played, it seems it adds a transparent bar on the top and on the bottom of the video.
The video is 720x576 (aspect ratio 5/4) and the idea was to adapt the aspect ratio to 16/9. With video_player I can easily adapt the aspect ratio for the video, but with fvp, I can't do this due to the top and bottom bars.
This behaviour seems to happen only with some videos.
I have attached some screenshots for reference. The first two screenshots are taken using the standard
video_player
package (without enabling "fvp"), and the other two with "fvp" enabled.Video player with original video aspect ratio:![Screenshot_1697900892](https://github.com/wang-bin/fvp/assets/46611368/29b14c93-bc6b-4ff3-8ee1-5ba3e87f8022)
Video player with forced 16/9 aspect ratio:![Screenshot_1697900907](https://github.com/wang-bin/fvp/assets/46611368/7617074c-1264-4bf3-a62d-4ff804bfcf98)
fvp with original video aspect ratio:![Screenshot_1697900863](https://github.com/wang-bin/fvp/assets/46611368/e10b76d3-8543-4188-87fa-561b7b37a951)
fvp with forced 16/9 aspect ratio![Screenshot_1697900875](https://github.com/wang-bin/fvp/assets/46611368/2048163d-81c8-4228-b6fa-87602ad541cf)
This is the example code with the stream url. Replace the
aspectRatio: _controller.value.aspectRatio,
part withaspectRatio: 16/9,
to force the 16/9 aspect ratio.Log log.txt