RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
236 stars 28 forks source link

Playback HLS from local storage #178

Closed SteenPetersen closed 3 years ago

SteenPetersen commented 5 years ago

Describe the bug I have been asked the post what seems like a possible bug (ref)

I am building a simple video player for the oculus GO and loading the .m3u8 file along with its .ts files into a folder on the headset. I find the file by accessing the oculus Go's internal storage and finding the location where I placed it. I have done this before for another app on the Oculus Quest with no issue. My debug log says that it does find the video, but it wont play it. Just a black screen, no sound either. Works fine in the editor:

Your Setup (please complete the following information):

To Reproduce

1. Take A high resolution .mp4 video and convert it to .m3u8 with FFMPEG using the following command:

ffmpeg -i inputVideo.mp4 -profile:v baseline -level 3.0 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls nameOfTheHLSvideo.m3u8

2. Load the resultant file into a folder on the oculus headset (In my case Android - data - _Videos)

3. Access the file from unity Editor and confirm it plays when finding it on a desktop

path = "D:\\SomeFolderOnYourDDrive\\nameOfTheHLSvideo.m3u8";

mediaPlayerVariable.OpenVideoFromFile(
MediaPlayer.FileLocation.AbsolutePathOrURL, 
path, 
true
);

4. Now try and see if it can be loaded on the oculus Go:

if (Application.platform == RuntimePlatform.Android)
   {
      rootPath = Application.persistentDataPath.Substring(
         0, 
         Application.persistentDataPath.IndexOf("Android", StringComparison.Ordinal));
      path = Path.Combine(
          Path.Combine(rootPath, "Android/Data/_Videos"), 
          fileName);
   }

if (!File.Exists(path))
    _debugText.text += "\nFile NOT found!\n\nChecking Path " + path + "\n\n";

mediaPlayerVariable.OpenVideoFromFile(MediaPlayer.FileLocation.AbsolutePathOrURL, path, true);

Result

The Debug log that should fire saying that it cannot find a video is NOT fired meaning that it does in fact find the video but the screen is just black, no sound.

SteenPetersen commented 5 years ago

Any news on this?

Ste-RH commented 4 years ago

@SteenPetersen Sorry for the slow response.

So you are trying to playback an HLS stream where the manifest and segments are stored locally to the Android device?

If so, that is not supported. HLS requires it to come in over HTTP traffic currently. It is something that I believe might be supported in the latest versions of ExoPlayer (via download/cached directory), but not something we currently support in AVPro Video.

May I ask why you require local HLS stream playback?

Ste-RH commented 4 years ago

We shall be closing this bug soon should there be no response forthcoming

RemyRM commented 4 years ago

@RenderHeadsSte I am running into the same issue but on generic Android (using ExoPlayer)/iOS devices (If you rather have me open up a separate question let me know, decided this issue is close enough to mine to reply instead).

As for why I would like local HLS stream playback (and assume OP wants something similar): In our Unity application we play back quite a lot of different, but not too lengthy videos. To save on mobile data usage we store the last N .ts files (and their appropriate .m3u8 headers) in the persistent data path, so that if the user decides to rewatch that video (granted that it hasn't been recycled away) they do not need to stream it again , but instead play it from the local storage.

Due to also wanting to support low-end devices caching in memory is not an option, having the ability to save HLS streams to the persistentDataPath and playing them back seemed like a good alternative.

My current (working) flow looks like this when a user wants to view a video for the first time:

Then the flow I would like for when a is replayed:

I didn't know about HLS only being able to be played back if the source is HTTP (Although seeing the name it probably makes sense....), is this something Apple forces through their implementation? Loading from any local storage location does work in the editor.

Now I can work around this by still requesting the video through the intermediate local HTTPListener, and then serving the HTTPListener from localhost. As far as the mediaplayer is concerned it comes over HTTP then, but doing this seems kinda redundant.

Somewhat related is this feature request I put in last year, asking if saving HLS streams to local storage would be possible through AVPro, but I guess that would be a useless feature if it can't be played back due to implementation anyway.

Thank you for your time!

Ste-RH commented 4 years ago

Converting this from a bug to an enhancement.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically closed because it has not had recent activity. If you wish to continue this issue, then please create a new issue as we do not monitor closed issues.

fingerx commented 3 years ago

any update news@RenderHeadSte@AndrewRH thanks

Ste-RH commented 3 years ago

The ability to playback HLS from local storage was added to Android in v2.0.2. We are not able to back port this to v1.x.