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
126 stars 20 forks source link

playing a m3u8 file throws error #15

Closed abdelaziz-mahdy closed 10 months ago

abdelaziz-mahdy commented 10 months ago

Exception: No Stream for textureId: -1.

logs

flutter: mdk.INFO: 2023-08-21 22:34:00.745069: default0x13bc5e300 virtual void mdk::FrameReader::stop(), current state: 0
flutter: mdk.INFO: 2023-08-21 22:34:00.745098: default FrameReader0x13bc5e300 state: 0=>0=>0, 0
flutter: mdk.INFO: 2023-08-21 22:34:00.745124: default0x13bc5e300 virtual void mdk::FrameReader::stop(), current state: 0
flutter: mdk.INFO: 2023-08-21 22:34:00.745152: AudioQueueStart ERROR: 0
flutter: mdk.INFO: 2023-08-21 22:34:00.745178: 0x13c8a9c00 MediaControl.prepare(0, ...) file:///Users/AbdelazizMahdy/Library/Containers/com.zezo357.flutterMeeduVideoplayerExample/Data/Library/Caches/hls1920x858.m3u8
flutter: mdk.INFO: 2023-08-21 22:34:00.745212: default 0x13bc5e300 FrameReader.start(0, ...)
flutter: mdk.INFO: 2023-08-21 22:34:00.745239: default 0x13bc5e300 FrameReader::update MediaStatus 0=>0X2
flutter: fvp.FINE: 2023-08-21 22:34:00.746487: 205690717 player5298360736 onMediaStatusChanged: MediaStatus(noMedia) => MediaStatus(+loading)
flutter: mdk.INFO: 2023-08-21 22:34:00.746876: default FrameReader0x13bc5e300 state: 0=>0=>1, 0
flutter: mdk.INFO: 2023-08-21 22:34:00.746911: default FrameReader0x13bc5e300 state: 0=>1=>1, 0
flutter: mdk.INFO: 2023-08-21 22:34:00.746938: start frame reader thread: 0x16e287000
flutter: mdk.WARNING: 2023-08-21 22:34:00.747: Failed to create io for url. io: 0x0, open: false
flutter: mdk.INFO: 2023-08-21 22:34:00.747025: default 0x13bc5e300 FrameReader::update MediaStatus 0X2=>0X2
flutter: mdk.INFO: 2023-08-21 22:34:00.747054: before avformat_open_input. io: 0x0(/pb: 0x0, url: file:///Users/AbdelazizMahdy/Library/Containers/com.zezo357.flutterMeeduVideoplayerExample/Data/Library/Caches/hls1920x858.m3u8
flutter: mdk.INFO: 2023-08-21 22:34:00.747087: [FFmpeg:hls] Skip ('#EXT-X-VERSION:3')
flutter: mdk.INFO: 2023-08-21 22:34:00.747113: [FFmpeg:hls] Skip ('#EXT-X-INDEPENDENT-SEGMENTS')
flutter: mdk.INFO: 2023-08-21 22:34:00.747144: [FFmpeg:hls] Opening 'https://videos-cloudfront-usp.jwpsrv.com/64e464e8_090aced23f8c47ee6c94e0361208b9bb9c8f36c1/site/zWLy8Jer/media/vM7nH0Kl/version/21ETjILN/manifest.ism/manifest-audio_eng=112000-video_eng=3279704.m3u8' for reading
flutter: mdk.INFO: 2023-08-21 22:34:00.747172: [FFmpeg:https] Protocol 'https' not on whitelist 'file,crypto,data'!
flutter: mdk.INFO: 2023-08-21 22:34:00.747198: [FFmpeg:hls] parse_playlist error Invalid argument [https://videos-cloudfront-usp.jwpsrv.com/64e464e8_090aced23f8c47ee6c94e0361208b9bb9c8f36c1/site/zWLy8Jer/media/vM7nH0Kl/version/21ETjILN/manifest.ism/manifest-audio_eng=112000-video_eng=3279704.m3u8]
flutter: mdk.INFO: 2023-08-21 22:34:00.747227: Error avrt::avformat_open_input(&fmtctx_, ffmpeg::from_file_uri(in.c_str()), fmt, &dict) @207 /Users/runner/work/mdk-sdk/mdk-sdk/mdk/ffmpeg/plugin/FFmpegPacketIO.cpp: (0xffffffea) Invalid argument
flutter: mdk.INFO: 2023-08-21 22:34:00.747257: 0x16e287000default 0x13bc5e300 bool mdk::FrameReader::update(mdk::MediaStatus) @1057: reset status_mask
flutter: mdk.INFO: 2023-08-21 22:34:00.747287: default 0x13bc5e300 FrameReader::update MediaStatus 0X2=>0X80000000
flutter: fvp.FINE: 2023-08-21 22:34:00.747337: 205690717 player5298360736 onMediaStatusChanged: MediaStatus(+loading) => MediaStatus(+invalid)
[flutter_meedu_videoplayer] Exception: No Stream<VideoEvent> for textureId: -1.
flutter: mdk.WARNING: 2023-08-21 22:34:00.752752: reader open error
flutter: mdk.INFO: 2023-08-21 22:34:00.752915: default FrameReader0x13bc5e300 state: 0=>1=>0, 1
flutter: mdk.SEVERE: 2023-08-21 22:34:00.753201: state not changed!
[flutter_meedu_videoplayer] #0      MdkVideoPlayer.videoEventsFor
video_player_mdk.dart:207
#1      VideoPlayerController.initialize
video_player.dart:488
                            <asynchronous suspension>
#2      MeeduPlayerController.setDataSource
controller.dart:533
                            <asynchronous suspension>
#3      _M3u8ExamplePageState._setDataSource
m3u8_page_example.dart:285
                            <asynchronous suspension>

[flutter_meedu_videoplayer] Fit is BoxFit.fitWidth
flutter: mdk.INFO: 2023-08-21 22:34:00.761910: 0x13c8a9c00 virtual void mdk::MediaControlPush::setState(mdk::PlaybackState)@969 requested state 2=>0, current state 0. status: 0X80000000
flutter: mdk.INFO: 2023-08-21 22:34:00.762204: default FrameReader0x13bc5e300 state: 0=>0=>0, 0
flutter: mdk.INFO: 2023-08-21 22:34:00.762384: default0x13bc5e300 virtual void mdk::FrameReader::stop(), current state: 0
flutter: mdk.INFO: 2023-08-21 22:34:00.762516: AudioQueueStart ERROR: 0
flutter: mdk.INFO: 2023-08-21 22:34:00.762618: 0x13bce1750virtual mdk::Player::~Player()64
flutter: mdk.INFO: 2023-08-21 22:34:00.762830: setNext from -1 url:
flutter: mdk.INFO: 2023-08-21 22:34:00.762891: default FrameReader0x13bc5e300 state: 0=>0=>0, 0
flutter: mdk.INFO: 2023-08-21 22:34:00.762922: default0x13bc5e300 virtual void mdk::FrameReader::stop(), current state: 0
flutter: mdk.INFO: 2023-08-21 22:34:00.762949: mdk::MediaPlayer::Private::~Private()
flutter: mdk.INFO: 2023-08-21 22:34:00.762976: 0x13c8a9c00 virtual void mdk::MediaControlPush::setState(mdk::PlaybackState)@969 requested state 0=>0, current state 0. status: 0X80000000
flutter: mdk.INFO: 2023-08-21 22:34:00.763009: AudioQueueStart ERROR: 0
flutter: mdk.INFO: 2023-08-21 22:34:00.763034: default0x13bc5e300 deleting FrameReader...
flutter: mdk.INFO: 2023-08-21 22:34:00.763058: 0x13c92e000 virtual void mdk::MediaControlPush::setState(mdk::PlaybackState)@969 requested state 0=>0, current state 0. status: 0
flutter: mdk.INFO: 2023-08-21 22:34:00.763090: AudioQueueStart ERROR: 0
flutter: mdk.INFO: 2023-08-21 22:34:00.763115: default0x13bcec1f0 deleting FrameReader...
flutter: mdk.INFO: 2023-08-21 22:34:00.763336: player is destroyed
flutter: mdk.INFO: 2023-08-21 22:34:00.763582: mdk::VideoRenderer::Private::~Private() @125
AnonymHK commented 10 months ago

In android

url: https://content.jwplatform.com/manifests/vM7nH0Kl.m3u8

[√] Flutter (Channel stable, 3.13.0, on Microsoft Windows [Version 10.0.19044.1889], locale zh-CN) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.4.5) [√] Android Studio (version 2022.3) [√] VS Code (version 1.70.0) [√] Connected device (4 available) [√] Network resources

image

abdelaziz-mahdy commented 10 months ago

the fix is to set ffmpeg ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto i dont how it can be done in the package

https://github.com/wang-bin/mdk-sdk/wiki/Player-APIs#void-setpropertyconst-stdstring-key-const-stdstring-value Since 0.7.0. Set additional properties. Can be used to store user data, or change player behavior if the property is defined internally.

this only for predefined or it can be used to set ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto and if yes can you help me do it, or apply by default on video_player interface to allow m3u8 playback from files

wang-bin commented 10 months ago

https://github.com/wang-bin/fvp/blob/master/lib/src/video_player_mdk.dart#L121

try

player.setProperty('avio.protocol_whitelist', 'file,http,https,tcp,tls,crypto');
wang-bin commented 10 months ago

I will add an option in registerWith() to passthrough mdk options and player properties

abdelaziz-mahdy commented 10 months ago

I will add an option in registerWith() to passthrough mdk options and player properties

That will be awesome, just as an idea, maybe as a map and they get set on the launch of the player?

I don't know if that will make the start of the video slow or not, it's just a thought

wang-bin commented 10 months ago

I will add an option in registerWith() to passthrough mdk options and player properties

That will be awesome, just as an idea, maybe as a map and they get set on the launch of the player?

Yes. It's the only way to control the player backend.

I don't know if that will make the start of the video slow or not, it's just a thought

No. The speed depends on network, stream bit rate etc, not simple lines of code.

abdelaziz-mahdy commented 10 months ago

I will add an option in registerWith() to passthrough mdk options and player properties

That will be awesome, just as an idea, maybe as a map and they get set on the launch of the player?

Yes. It's the only way to control the player backend.

I don't know if that will make the start of the video slow or not, it's just a thought

No. The speed depends on network, stream bit rate etc, not simple lines of code.

That's awesome then❤️

abdelaziz-mahdy commented 10 months ago

https://github.com/wang-bin/fvp/blob/master/lib/src/video_player_mdk.dart#L121

try

player.setProperty('avio.protocol_whitelist', 'file,http,https,tcp,tls,crypto');

i can confirm adding the line made it work

    final player = mdk.Player();
    _log.fine('$hashCode player${player.nativeHandle} create($uri)');
    if (_options is Map<String, dynamic>) {
      player.videoDecoders = _options['video.decoders'];
    }
    if (dataSource.httpHeaders.isNotEmpty) {
      String headers = '';
      dataSource.httpHeaders.forEach((key, value) {
        headers += '$key: $value\r\n';
      });
      player.setProperty('avio.headers', headers);
    }
    player.setProperty('avio.protocol_whitelist', 'file,http,https,tcp,tls,crypto');

just a suggestion if that can be the default it will be easier on people and it will be the same as video_player

abdelaziz-mahdy commented 10 months ago

should i close this issue, or leave it until the release?