canalplus / rx-player

DASH/Smooth HTML5 Video Player
https://developers.canal-plus.com/rx-player/
Apache License 2.0
861 stars 131 forks source link

playing MKV VOD with multi Audio track #1388

Open iptvsmartws opened 7 months ago

iptvsmartws commented 7 months ago

Hi

Does RX-player support playing mkv link from MSE source with multi audio and subtitles ? consider using this in webos web based app

peaBerberian commented 7 months ago

Hi,

I'm not sure I understand your use case:

  1. Do you want to play mkv files directly on a page?
  2. Or do you rely on something like DASH or Smooth with the media files being mkv files?

If it's the (1), this is what we call "directfile" mode in the RxPlayer. Support of both the media and of track listing will mostly depend on browser capabilities, you can do a test like this:

const player = new RxPlayer({ videoElement: YOUR_VIDEO_ELEMENT_TAG });
player.loadVideo({
  transport: "directfile",
  url: URL_TO_YOUR_MKV_FILE,
});

// Let's just list audio and text tracks once loaded
player.addEventListener("playerStateChange", (state) => {
  if (state === "LOADED") {
    const audioTracks = player.getAvailableAudioTracks();
    const textTracks = player.getAvailableTextTracks();

    console.log("audio tracks:", audioTracks);
    console.log("text tracks:", textTracks);
  }
});

If it's the (2), we should, yet again the container format has to be understood by the browser. For example if you rely on DASH, you can just rewrite the previous example, replacing "directfile" by "dash" and the url to the URL to your MPD file.

iptvsmartws commented 7 months ago

its a direct file but in xtream code iptv server, so from media source extension link is similar to this : http://server:port/movie/username/password/vod.mkv

Any change for this ?

peaBerberian commented 7 months ago

I'm sorry, I'm unsure of what "media source extension link" means here.

To me "Media Source Extensions" refers only to a browser-side API specification, and I thus don't understand how a remote resource could be qualified as "MSE".

Does your link return an mkv file or a more complex response? Is it qualified as "MSE" because a player is expected to perform range requests on it (or perhaps setting up even more complex headers/url)?

Does it work if you create a page with a video element pointing to that link:

<video src="http://server:port/movie/username/password/vod.mkv"></video>

If it does, you can just test by relying on the "directfile" example.

iptvsmartws commented 7 months ago

I've successfully implemented multi-audio track support using RxPlayer from the CDN at https://unpkg.com/rx-player@4.0.0/dist/rx-player.min.js. However, I'm facing challenges with enabling subtitles. Could someone provide a comprehensive example that demonstrates using RxPlayer for direct file playback with both multiple audio tracks and subtitle support? Additionally, I'm interested in best practices for video optimization, including features like seeking, quick forward/backward (+10 seconds/-10 seconds), and automatic resumption after disconnection.

peaBerberian commented 7 months ago

I've successfully implemented multi-audio track support using RxPlayer from the CDN at https://unpkg.com/rx-player@4.0.0/dist/rx-player.min.js.

Nice to hear! Did you play the corresponding mkv files (in which case does it work on WebOS?) or another file format?

However, I'm facing challenges with enabling subtitles. Could someone provide a comprehensive example that demonstrates using RxPlayer for direct file playback with both multiple audio tracks and subtitle support?

Our track selection tutorial should have you covered: https://developers.canal-plus.com/rx-player/doc/Getting_Started/Tutorials/Selecting_a_Track.html Though I'm here if parts of it are unclear or not functional for your case.

Additionally, I'm interested in best practices for video optimization, including features like seeking, quick forward/backward (+10 seconds/-10 seconds), and automatic resumption after disconnection.

To seek in general, you can just rely on our seekTo API.

automatic resumption after disconnection

If you don't want to fail on error on disconnection, you can just update the requestConfig loadVideo option:

rxPlayer.loadVideo({
  // ...
  requestConfig: {
    // Retry both segment and manifest requests until they are reachable
    segment: { maxRetry: Infinity },
    manifest: { maxRetry: Infinity },
  },
});

The RxPlayer has then an algorithm to determine whether a retry makes sense after a request error (e.g. it makes sense on disconnection but it makes less sense after an http 403) and will have retry mechanisms preventing a CDN from being too much solicited on consecutive retry (through what's called a "truncated exponential backoff").

iptvsmartws commented 7 months ago

I can confirm that playback works on WebOS without any issues. Additionally, when the Experimental Web Platform features are enabled in edge://flags/, MKV files with sound play well in Microsoft Edge. However, I've noticed that Chrome does not support this playback scenario for MKV files with sound, even with experimental features turned on.

for subtitles , it does not show even in the adnaced demo page hosted for rxplayer

image

iptvsmartws commented 5 months ago

any update ?