I try to play a vp8 video on an Android device (Galaxy S10e, Android 12) using VideoPlayer.url with a file URI.
For example:
videoPlayer.url = "file:///storage/emulated/0/Android/data/com.my.app/files/videos/test.webm"
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: Supported media formats | Android media | Android Developers
Further, Unity docs suggests to use vp8 for best cross-platform compatibility: Unity - Manual: Video file compatibility
Still, I see the following errors in Logcat when trying to use a .vp8 video on Android:
2022.03.20 08:59:43.439 1389 1487 Verbose NuMediaExtractor NuMediaExtractor constructor
2022.03.20 08:59:43.440 1389 1487 Error NdkMediaExtractor can't create http service
2022.03.20 08:59:43.441 1389 1487 Warn Unity AndroidVideoMedia: Error opening extractor: -10002
2022.03.20 08:59:43.441 1389 1487 Verbose NuMediaExtractor NuMediaExtractor destructor
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
2022.03.20 08:59:43.447 1389 1429 Error Unity Cannot read file.
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
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?
achimmihca:
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?
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/62878148/picking-video-file-on-android-10-error-ndkmediaextractor-cant-create-http-serv
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: GitHub - achimmihca/unity-vp8-video-test: Playing VP8 encoded video file on Android using Unity
I also created a Unity bug report (CASE IN-10816).
1 Like
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.
The issue seems to be fixed in 2023.1.0b1
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