Skip to content
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

Video takes a long time to start playing and using a lot of CPU #207

Closed
insinfo opened this issue Jan 24, 2022 · 6 comments
Closed

Video takes a long time to start playing and using a lot of CPU #207

insinfo opened this issue Jan 24, 2022 · 6 comments

Comments

@insinfo
Copy link

insinfo commented Jan 24, 2022

I put dart vlc in my flutter app and I see that
Video takes a long time to start playing and is using a lot of CPU.
takes about 10 seconds to start playback.
It's using around 22% CPU.

image

import 'package:dart_vlc/dart_vlc.dart';
import 'package:flutter/material.dart';

import 'package:riodasostrasapp/app/shared/theme/style.dart';

class TurismoHomePage extends StatefulWidget {
  @override
  State<TurismoHomePage> createState() => _TurismoHomePageState();
}

class _TurismoHomePageState extends State<TurismoHomePage> {
  late Player player;
  @override
  void initState() {
    player = Player(id: 69420);
    var media2 = Media.network(
        'https://www.experimenteriodasostras.com.br/storage/turismo/midias/ffec8800-09d2-45a4-9b99-09ab04b057bf.mp4');
    player.open(media2);
    player.playbackStream.listen((PlaybackState state) {
      if (state.isCompleted) {
        player.play();
      }
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    var screenSize = MediaQuery.of(context).size;

    return Scaffold(
      appBar: appBarDefault(title: 'Turismo'),
      body: Container(
        //padding: EdgeInsets.all(0),
        child: SingleChildScrollView(
          child: Column(
            children: [
              //video
              Container(
                color: Colors.amber,
                width: screenSize.width,
                height: 250,
                child: Video(
                  player: player,
                  scale: 1.0, // default
                  showControls: false, // default
                ),
              ),
              //menu grid
              Container(
                padding: EdgeInsets.all(16),
                width: screenSize.width,
                child: Wrap(
                  spacing: 16,
                  runSpacing: 16,
                  children: [
                    Container(
                      decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.all(Radius.circular(10))),
                      padding: EdgeInsets.all(10),
                      child: Column(
                        children: [
                          Text(
                            '',
                            style: TextStyle(
                                fontFamily: 'pictogramas_turismo',
                                fontSize: 71),
                          )
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    player.stop();
    player.dispose();
    super.dispose();
  }
}
PS C:\MyDartProjects\riodasostras\riodasostrasapp_mob> flutter run --release
Launching lib\main.dart on Windows in release mode...
Building Windows application...                                         

Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
flutter: LoginController chamou contrutor
flutter: ContrachequeController chamou contrutor
flutter: AppModule started!
flutter: -- HomeModule INITIALIZED
flutter: initHomePageState:
flutter: -- TurismoModule INITIALIZED
flutter: -- TurismoModule DISPOSED
[00000263f3c311c0] main filter error: Failed to create video converter
[00000263f7136ef0] main vout display error: Failed to set on top
[00000263f3c318a0] main filter error: Failed to create video converter
[00000263f7022890] main vout display error: Failed to set on top
[h264 @ 00000263f3da15a0] get_buffer() failed
[h264 @ 00000263f3da15a0] thread_get_buffer() failed
[h264 @ 00000263f3da15a0] decode_slice_header error
[h264 @ 00000263f3da15a0] no frame!
[h264 @ 00000263f3da19e0] get_buffer() failed
[h264 @ 00000263f3da19e0] thread_get_buffer() failed
[h264 @ 00000263f3da19e0] decode_slice_header error
[h264 @ 00000263f3da19e0] no frame!
PS C:\MyDartProjects\riodasostras\riodasostrasapp_mob> flutter doctor -v    
[√] Flutter (Channel stable, 2.8.1, on Microsoft Windows [versão 10.0.22000.434], locale pt-BR)
    • Flutter version 2.8.1 at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (6 weeks ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at C:\Users\isaque\AppData\Local\Android\sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.3)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.31702.278
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] VS Code (version 1.63.2)
    • VS Code at C:\Users\isaque\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.32.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [versão 10.0.22000.434]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 97.0.4692.71
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 96.0.1054.62

• No issues found!
@alexmercerind
Copy link
Owner

It's not hardware accelerated & there's nothing I can do. Same issue reported at #184.

About "Video takes a long time to start playing", then its the issue of your network possibly not the plugin.

@insinfo
Copy link
Author

insinfo commented Jan 24, 2022

@alexmercerind

About "Video takes a long time to start playing", then its the issue of your network possibly not the plugin.

In google chrome directly accessing the URL the playback starts in less than 2 seconds

image

@alexmercerind
Copy link
Owner

alexmercerind commented Jan 24, 2022

In google chrome directly accessing the URL the playback starts in less than 2 seconds

If the opening time is faster in VLC app compared to this plugin, then I can certainly say its a fault in plugin otherwise I can do nothing.

Note that release/debug mode can also affect how things perform.

@insinfo
Copy link
Author

insinfo commented Jan 24, 2022

I installed vlc on my computer and it seems to be a problem with vlc itself, as it takes an average of 12 seconds for vlc to start playing the video so I opened an issue in the vlc repository.
https://code.videolan.org/videolan/vlc/-/issues/26539

I did a test with the plugin "video_player_windows" and it manages to start playing the video in less than 2 seconds in flutter debug mode, the only problem I saw in video_player_windows is that it keeps the video blinking.
anirudhb/flutter_packages#3

@sadikul1500
Copy link

@insinfo How did you solve the following error?
image

@insinfo
Copy link
Author

insinfo commented Oct 10, 2022

@sadikul1500
even with these errors in the log the video plays well after 10 seconds, I believe these errors must come from the vlc shared library and not the plugin I think.

try reporting the problem at this link
https://code.videolan.org/videolan/vlc/-/issues/26539

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

3 participants