Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug VideoPlayer.url issue with vp8/webm on Android: AndroidVideoMedia: Error opening extractor: -10002

Discussion in 'Audio & Video' started by achimmihca, Mar 20, 2022.

  1. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    266
    I try to play a vp8 video on an Android device (Galaxy S10e, Android 12) using VideoPlayer.url with a file URI.
    For example:
    Code (csharp):
    1.  
    2. videoPlayer.url = "file:///storage/emulated/0/Android/data/com.my.app/files/videos/test.webm"
    3.  
    Note that
    - the video is not present at compile time. The user selects the path at runtime.
    - this works perfectly fine with a .mp4 file on Android.
    - this works perfectly fine with a .vp8 (also with a .webm file) on Windows.

    However, it does not work with a vp8 file on Android (neither with .vp8 nor with .webm file extension).

    But, according to Android docs, vp8 should be supported by Android: https://developer.android.com/guide/topics/media/media-formats.html#recommendations

    Further, Unity docs suggests to use vp8 for best cross-platform compatibility: https://docs.unity3d.com/Manual/VideoSources-FileCompatibility.html
    Still, I see the following errors in Logcat when trying to use a .vp8 video on Android:
    Code (csharp):
    1.  
    2. 2022.03.20 08:59:43.439 1389 1487 Verbose NuMediaExtractor NuMediaExtractor constructor
    3. 2022.03.20 08:59:43.440 1389 1487 Error NdkMediaExtractor can't create http service
    4. 2022.03.20 08:59:43.441 1389 1487 Warn Unity AndroidVideoMedia: Error opening extractor: -10002
    5. 2022.03.20 08:59:43.441 1389 1487 Verbose NuMediaExtractor NuMediaExtractor destructor
    6. 2022.03.20 08:59:43.447 1389 1429 Error Unity VideoPlayer cannot play url : file:///storage/emulated/0/Android/data/com.Karaoke.UltraStarPlay/files/Songs/d - d/d - d.webm
    7. 2022.03.20 08:59:43.447 1389 1429 Error Unity Cannot read file.
    8.  
    I assume that the log messages for NuMediaExtractor are part of the issue, but I am not sure.

    Questions:
    - is .vp8 on Android supported by Unity?
    - if yes, what is wrong here? How to play .vp8 file on Android via VideoPlayer.url?
    - can others confirm this issue?

    Unity version: 2021.2.0f1
     
  2. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    266
    Is there a single video file format that works out of the box at runtime with Unity's VideoPlayer.url on Windows, MacOS, Linux, Android and iOS?
     
  3. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    497
    We support webm across all platforms, but I am unsure about vp8 files. Something you should try is removing the files:// from the path and making sure the file is where you think it is. I saw someone else having the same issue https://stackoverflow.com/questions...error-ndkmediaextractor-cant-create-http-serv
     
  4. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    266
    > Something you should try is removing the files:// from the path

    This works.

    Still I consider this a bug, because
    - using file:// scheme prefix makes the URI complete
    - the file:// scheme prefix works with other file formats on Android and on other platforms (I think it may even be required sometimes)
    - the number of error log messages seems fishy to me. Unity could handle this better.

    I created a sample project to test and reproduce the issue: https://github.com/achimmihca/unity-vp8-video-test
    I also created a Unity bug report (CASE IN-10816).
     
    The_Island likes this.
  5. exsurgo_ankit

    exsurgo_ankit

    Joined:
    Feb 5, 2020
    Posts:
    29
    I am building in Unity 2021.3.17f1 and I have to exclude the prefix file:// for mp4 files to be loaded into video player.
    Otherwise I get the same error
    Unity AndroidVideoMedia: Error opening extractor: -10002

    Note that I change the VideoPlayer's source to url at runtime when the files are downlaoded from our server.
     
  6. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    266
  7. The_Island

    The_Island

    Unity Technologies

    Joined:
    Jun 1, 2021
    Posts:
    497
    Yeah, I fixed it, and it should be backported at one point. The issue was that on Android Application.persistentDataPath start with jar:file://. So when you add file:// in front of Application.persistentDataPath, you get file://jar:file:// which the virtual file storage doesn't know how to handle it