Search Unity

Video Looping video not working on Android (MP4)

Discussion in 'Audio & Video' started by ZO5KmUG6R, Dec 2, 2018.

  1. ZO5KmUG6R

    ZO5KmUG6R

    Joined:
    Jul 15, 2010
    Posts:
    490
    Hey, so today I tried to play an Mp4 file and loop it. I set isLooping to true, and it worked in the editor, and on a Windows standalone player.

    I then made an Android build, and when the video reached the loop point, it just went blank. There was an error logged in the logcat console

    "AndroidVideoMedia::SetSecPosition seekTo error: -10000"

    I was also unable to manually loop it ,as setting the time to 0, then calling Play(), resulted in a freeze on the first frame.

    I'm posting here because Unity devs seem to frequent this area of the forum. While I could submit a bug report, that takes a lot of time and I'd have to go through the process of making a seperate project. Since I've found a workaround (webm works perfectly), and I don't absolutely need mp4, it feels like it's more effort than it's worth.

    (This problem occured with 2018.3.0b12 and 0b7)
     
  2. msclower

    msclower

    Joined:
    May 26, 2017
    Posts:
    13
    Did you have any luck with this? I have raised a support log for it as i managed to reproduce this using in 2018.3 but was working on 2017.3. However the looping did not work for me on android 4.1.1 devices. Devices on 4.3 and above it worked.
     
  3. ZO5KmUG6R

    ZO5KmUG6R

    Joined:
    Jul 15, 2010
    Posts:
    490
    Not really. Right now I have a video file that loops randomly (maybe about 60% of the time) :(
     
  4. wavekeyboard

    wavekeyboard

    Joined:
    Apr 7, 2017
    Posts:
    4
    Same here, I got these errors in logcat:

    (Filename: ./PlatformDependent/AndroidPlayer/Modules/Video/Private/AndroidVideoMedia.cpp Line: 1409)
    W/Unity: AndroidVideoMedia::SetSecPosition seekTo error: -10006

    NuMediaExtractor: read on track 0 failed with error

    HwExtendedCodec: mime: video/avc matching compontent failed!​

    Happens all the time on newer Huawei devices. Tested on HUAWEI ANE-LX1, Huawei P Smart 2017, Huawei P30 Pro.
    The movie files are H264 encoded, and not all files have these problem but can't find any differences between them.

    Tested with Unity versions 2019.3.0a7, 2019.1.6f1

    It may be worth trying an Exoplayer plugin to play videos natively on Android
     
    Last edited: Jul 4, 2019
  5. wavekeyboard

    wavekeyboard

    Joined:
    Apr 7, 2017
    Posts:
    4
    Seems to work if Transcoding for Android with VP8 Codec
     

    Attached Files:

  6. HashBakshish

    HashBakshish

    Joined:
    Jun 26, 2018
    Posts:
    2
    Hello,

    My Video and audio get stuck randomly while playing on in android device. It shows this error on android studio.

    W/NuMediaExtractor: read on track 0 failed with error -2147483646
     
    josefgrunig and wavekeyboard like this.
  7. paulksi

    paulksi

    Joined:
    Nov 9, 2015
    Posts:
    27
    Hey I get the same reslut on Samsung Tab S5e, did you find any solution??
     
  8. Fangh

    Fangh

    Joined:
    Apr 19, 2013
    Posts:
    274
    I had the same issue on HTC Vive Focus with a 4k 360° video. I lowered the bitrate of my video and it's now working.
     
    josefgrunig likes this.
  9. paulksi

    paulksi

    Joined:
    Nov 9, 2015
    Posts:
    27
    The only proper solution is AVPro video plugin for android its pricey but it works without any lags with high res.
    Spent over 2 weeks with samsung s5e fixing this bug and what can i say - useless, nothing helped except AVPro.
     
  10. josefgrunig

    josefgrunig

    Joined:
    Jan 23, 2017
    Posts:
    62
    Reducing the bitrate is the proper solution. See Android recommendations: https://developer.android.com/guide/topics/media/media-formats

    Personally I use below 2Mbps
     
  11. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    I just faced this problem yesterday.
    Reducing the encoding quality of the video (hence the bitrate) DOESN'T fix it.
    The issue seems to relate to the actual pixel size of the video and which codec you use.
    With H264, you can't go higher than 1280x720 or 1024x1024 without the video crashing.
    For H265 however, you can use 1920x1080 with max quality settings without issues.
    VP8 seems to be a good candidate for FullHD videos too.
    Just avoid H264 for larger videos.
    I don't know if this is actually a bug from Unity's or Android side of things. It could be a problem with the size of the video buffer that Unity allocates internally on H264 or it could be a system wide thing, although it's unlikely since I'm having 1080p H264 videos crashing Unity on my Nvidia Shield while I daily use it to play 1080p H264 videos from my Plex server without issues (and with a WAY higher bitrate).
    Someone should probably fill a bug report to let them know.