albemala / native_video_player

A Flutter widget to play videos on iOS and Android using a native implementation.
MIT License
14 stars 12 forks source link

video resolution #4

Open mranderson02005 opened 1 year ago

mranderson02005 commented 1 year ago

hi, with a little nudging Androids manifest with file permissions I managed to get this working on my android computer, but the video is 4k but it seems to be playing at hd or lower. it looks a little fuzzy. Is there any way to improve that?

I am using your example project, and I changed asset to file and am playing a local file.

albemala commented 1 year ago

hey there,

it sounds like a limitation in Android or your device. this package uses the VideoView directly and it should take care of everything automatically (from a display point of view).

I'd suggest trying with another package as well, like https://pub.dev/packages/video_player, and see if you have the same problem or not. if not, I can try to dig more into the issue.

mranderson02005 commented 1 year ago

Hey thanks for getting back!

I'm on android 9, on a odroid n2 device, its resolution is set to 4k as well as the screen, and android video apps are playing 4k videos.

I have tried the official video_player, I am actually trying most of them till I get it working right. I also have the same problem there.

albemala commented 1 year ago

interesting... what about images at 4k resolution, do they look alright in flutter apps on your device/screen? I wonder if it's a problem with flutter in general not supporting 4k somehow

mranderson02005 commented 1 year ago

So I tried doing a testimage meant for 4k, it is very hard to find a marketplace app that will actually display it pixel for pixel. I have compared the image from my macbook hdmi output and the image is entirely without jagged edges and has more detail in small numbers.

So actually compared to many apps from the marketplace the 4k image photo I get out of flutter is pretty good, but still has a hint of HD because of the unclear small text. The video playing from VLC looks 4k, but now I am wondering maybe it is not so sharp because I dont have the video exactly 4k pixel for pixel scaled, so there is some downscaling happening which is causing the blurriness of the image.

I have to see how I make my video screen filling without any android navigation and statusbars to make a good check.

mranderson02005 commented 1 year ago

apart from the resolution, I can't actually get the example app to display video now, it is just black but I hear audio. When I quit the app from flutter, stopping debug, I briefly see the video as it closes.

From what I read there is a video view and a UI view in android, to be able to play 4k video on many android devices you need to use the video layer, not the ui, the ui is always 2k. I wonder if flutter always uses the UI view?

final videoSources = [ ExampleVideoSource( path: '/storage/3D016CC97DA901C4/testclip2.mp4', type: VideoSourceType.file), ]; I am using this to play the file of a local drive but still I get this message: W/MediaPlayer( 6536): Couldn't open /storage/3D016CC97DA901C4/testclip2.mp4: java.io.FileNotFoundException: No content provider: /storage/3D016CC97DA901C4/testclip2.mp4

I have android permissions in the manifest for read local storage, and I checked in Settings of android that the app has permissions for storage. It's strange because it is playing the video and I hear the audio. I have also swapped the videosource to the assets folder with 01.mp4 and I also get the fileIO error.

mranderson02005 commented 1 year ago

I redownloaded the example app, I can confirm it is now working normally (after adding permissions in the manifest for internet and read) and giving the app storage permissions in android settings. There are a lot of errors in the debug tho, also with references to exoplayer. I think the errors are related to this: Couldn't open /data/user/0/me.albemala.native_video_player_example/cache/assets/video/04.mp4: java.io.FileNotFoundException: No content provider: /data/user/0/me.albemala.native_video_player_example/cache/assets/video/04.mp4 it is able to access them, but somehow it is also checking in this other folder where it can't access it?

When I change the first videosources to my local file source, unfortunately it isn't working as described above. I think there might be an android 9 file access issue, the videoplayer from flutter that uses exoplayer is able to access it, but I think it puts it into File before searching for the file.

In the end, I do think it found the file because when I play it I hear the audio, but the duration of the video is not displayed correctly (54mins and the video is 21 hours), and of course the video is still black :(

UPDATE: after restarting the android n2 device I did have video working! I think somehow the videolayer was occupied or something, but still the image is not 4k :(

And I see the calculation now for the duration, that won't work for long videos like this I guess.

mranderson02005 commented 1 year ago

one more update: when I use the example code and swap out the network for a local file. I get the HD video playing, however, when I try to simplify the player, I get the black video issue. Any idea what that might be?

import 'dart:core';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:native_video_player/native_video_player.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky,
      overlays: []);
  runApp(
    const Video(),
  );
}

class Video extends StatefulWidget {
  const Video({super.key});

  @override
  State<Video> createState() => _VideoState();
}

class _VideoState extends State<Video> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: NativeVideoPlayerView(
        onViewReady: (controller) async {
          final videoSource = await VideoSource.init(
            path: '/storage/3D016CC97DA901C4/testclip2.mp4',
            type: VideoSourceType.file,
          );
          await controller.loadVideoSource(videoSource);
          controller.onPlaybackReady.addListener(() {
            controller.play();
            controller.seekTo(54000);
            controller.setVolume(1);
          });
          controller.onPlaybackEnded.addListener(() {
              controller.play();
            });
        },
      ),
    );
  }
}
albemala commented 1 year ago

hey @mranderson02005 , thanks for the update and for testing things out!

I'll have a look at the last issue you've mentioned and get back to you as soon as I can